Skip to content

Commit

Permalink
Merge pull request #52 from VahidGarousi/51-add-spotless
Browse files Browse the repository at this point in the history
Adding Spotless for #51
  • Loading branch information
VahidGarousi authored Jan 5, 2023
2 parents e96fb49 + fcc4eaf commit 9252053
Show file tree
Hide file tree
Showing 55 changed files with 388 additions and 398 deletions.
6 changes: 3 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ plugins {
}

android {
namespace 'dev.garousi.stock_watcher'
namespace 'dev.garousi.stockwatcher'
compileSdk 33

defaultConfig {
applicationId "dev.garousi.stock_watcher"
applicationId "dev.garousi.stockwatcher"
minSdk 23
targetSdk 33
versionCode 1
versionName "1.0"

testInstrumentationRunner "dev.garousi.stock_watcher.HiltTestRunner"
testInstrumentationRunner "dev.garousi.stockwatcher.HiltTestRunner"
vectorDrawables {
useSupportLibrary true
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.garousi.stock_watcher
package dev.garousi.stockwatcher

import android.app.Application
import android.content.Context
Expand All @@ -9,8 +9,8 @@ class HiltTestRunner : AndroidJUnitRunner() {
override fun newApplication(
cl: ClassLoader?,
className: String?,
context: Context?
context: Context?,
): Application {
return super.newApplication(cl, HiltTestApplication::class.java.name, context)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package dev.garousi.stock_watcher.feature.watchlist.presentation
package dev.garousi.stockwatcher.feature.watchlist.presentation

import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import com.google.common.truth.Truth.assertThat
import dev.garousi.stock_watcher.feature.watchlist.domain.repository.stocks
import dev.garousi.stock_watcher.ui.theme.StockWatcherTheme
import dev.garousi.stockwatcher.feature.watchlist.domain.repository.stocks
import dev.garousi.stockwatcher.ui.theme.StockWatcherTheme
import org.junit.Rule
import org.junit.Test


class StockItemTest {
@get:Rule
val composeTestRule = createComposeRule()
Expand All @@ -23,7 +22,8 @@ class StockItemTest {
setContent {
StockWatcherTheme(true) {
StockItem(
stock = actualStockItem, index = 0
stock = actualStockItem,
index = 0,
)
}
}
Expand All @@ -50,4 +50,4 @@ class StockItemTest {
assertThat(hasClickedOnStockItem).isTrue()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package dev.garousi.stock_watcher.feature.watchlist.presentation
package dev.garousi.stockwatcher.feature.watchlist.presentation

import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performScrollToIndex
import dev.garousi.stock_watcher.feature.watchlist.domain.models.Stock
import dev.garousi.stock_watcher.feature.watchlist.domain.repository.stocks
import dev.garousi.stock_watcher.ui.theme.StockWatcherTheme
import java.time.LocalTime
import java.util.UUID
import dev.garousi.stockwatcher.feature.watchlist.domain.models.Stock
import dev.garousi.stockwatcher.feature.watchlist.domain.repository.stocks
import dev.garousi.stockwatcher.ui.theme.StockWatcherTheme
import org.junit.Rule
import org.junit.Test

import java.time.LocalTime
import java.util.UUID

class StockListTest {
@get:Rule
Expand Down Expand Up @@ -75,8 +74,8 @@ class StockListTest {
min = min,
max = max,
ref = ref,
open = open
)
open = open,
),
)
}
with(composeTestRule) {
Expand Down Expand Up @@ -105,10 +104,8 @@ class StockListTest {
}
}
}

}


private val testStocks = arrayListOf<Stock>().apply {
add(
Stock(
Expand All @@ -124,8 +121,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1010.0
)
open = 1010.0,
),
)
add(
Stock(
Expand All @@ -141,8 +138,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -158,8 +155,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -175,8 +172,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -192,8 +189,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -209,8 +206,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -226,8 +223,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -243,8 +240,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -260,8 +257,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -277,8 +274,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -294,8 +291,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -311,8 +308,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -328,8 +325,8 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
add(
Stock(
Expand All @@ -345,7 +342,7 @@ private val testStocks = arrayListOf<Stock>().apply {
min = 999.0,
max = 1580.0,
ref = 124.0,
open = 1710.0
)
open = 1710.0,
),
)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package dev.garousi.stock_watcher.feature.watchlist.presentation
package dev.garousi.stockwatcher.feature.watchlist.presentation

import androidx.compose.ui.test.assertHasClickAction
import androidx.compose.ui.test.assertIsDisplayed
Expand All @@ -7,54 +7,51 @@ import androidx.compose.ui.test.junit4.ComposeContentTestRule
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.onChildren
import androidx.compose.ui.test.onNodeWithTag
import dev.garousi.stock_watcher.feature.watchlist.domain.models.Stock

import dev.garousi.stockwatcher.feature.watchlist.domain.models.Stock

fun ComposeContentTestRule.assertArrowIsDisplayed(
actualStockItemIndex: Int
actualStockItemIndex: Int,
) = onNodeWithTag(StockItemTestTags.arrow + actualStockItemIndex, true)
.assertIsDisplayed()

fun ComposeContentTestRule.assertPriceChangeIsDisplayed(
actualStockItemIndex: Int,
actualStockItem: Stock
actualStockItem: Stock,
) {
val expectedPriceChange =
buildString { append("+").append(actualStockItem.change) }

onNodeWithTag(
StockItemTestTags.priceChange + actualStockItemIndex,
true
true,
).assertIsDisplayed().assertTextEquals(expectedPriceChange)
}

fun ComposeContentTestRule.assertLastPriceIsDisplayed(
actualStockItemIndex: Int,
actualStockItem: Stock
actualStockItem: Stock,
) {
onNodeWithTag(
StockItemTestTags.lastPrice + actualStockItemIndex,
true
true,
).assertIsDisplayed().assertTextEquals(actualStockItem.last.toString())
}

fun ComposeContentTestRule.assertNameIsDisplayed(
actualStockItemIndex: Int,
actualStockItem: Stock
actualStockItem: Stock,
) {
onNodeWithTag(
StockItemTestTags.name + actualStockItemIndex,
true
true,
).assertIsDisplayed().assertTextEquals(actualStockItem.name)
}

fun ComposeContentTestRule.assertCardIsDisplayed(
actualStockItemIndex: Int
actualStockItemIndex: Int,
) = onNodeWithTag(StockItemTestTags.card + actualStockItemIndex).assertIsDisplayed()
.assertHasClickAction()



fun ComposeTestRule.getVisibleStockListSize(testTag: String): Int {
return onNodeWithTag(testTag).onChildren().fetchSemanticsNodes().size
}
}
Loading

0 comments on commit 9252053

Please sign in to comment.