-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
π 4λ¨κ³ - μ₯λ°κ΅¬λ(μλ) #70
base: s9hn
Are you sure you want to change the base?
Changes from all commits
7e0ffa5
65f3ff7
c007f36
07a86d6
2f21374
ea6b678
878d1f3
7c2ef86
f41d177
32311eb
d804962
ccca82f
290bce7
f23b826
fa78176
70faa27
f57d840
ecf9b6b
c64c3b3
91284ef
a07b9ba
12b8c38
bac6964
8beb557
8939020
5c8b5e6
468180e
b7cb31f
10500df
cbd7640
51d4e60
9a872ef
680fb72
19256d2
4970501
e572f50
3a50d2c
0700b31
1759fac
dd36132
73487e6
c0290b0
9ea84af
c3a7636
b30be9c
14a2c05
c21d971
6c2afae
92bfcae
773222f
f452a6f
d981bc6
763c4e2
773d20a
051b1e7
dd7c9bf
693cae7
e265431
c7e8b09
fdcd3df
04f3949
476a5a9
e371982
14a22bc
2f5be0d
c3ce6c1
f29ee0e
11bf0f4
ef5bb9e
bcb707f
becc96c
2bb360a
d2ec793
f941dde
f693298
2e800b7
1d04021
cb9f721
f87e788
a18ff4c
8939e91
47dd987
b171732
8377de7
b8f9d8b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
package nextstep.shoppingcart.shoppinglist.shoppinglist | ||
|
||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertIsNotDisplayed | ||
import androidx.compose.ui.test.assertTextEquals | ||
import androidx.compose.ui.test.isDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import nextstep.shoppingcart.ui.shoppinglist.ShoppingListScreen | ||
import nextstep.shoppingcart.ui.shoppinglist.model.Product | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ShoppingListScreenTest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μλ―Έ μλ μλ리μ€λ₯Ό μ λ§ μ λμΆν΄μ£Όμ
¨λ€μ π |
||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun μνμ_λ΄κΈ°_λ²νΌμ_λλ₯΄λ©΄_μλμ‘°μ _λ²νΌμ΄_λ ΈμΆλλ€() { | ||
// given: | ||
var products by mutableStateOf( | ||
listOf( | ||
Product( | ||
id = 0L, | ||
name = "ν μ€νΈ1", | ||
imageUrl = "", | ||
price = 110L, | ||
containedCount = 0, | ||
) | ||
) | ||
) | ||
|
||
composeTestRule.apply { | ||
setContent { | ||
ShoppingListScreen( | ||
products = products, | ||
onShoppingCartClick = {}, | ||
onItemClick = {}, | ||
onPutClick = { selectedProductId -> | ||
products = products.map { product -> | ||
if (selectedProductId == product.id) product.copy( | ||
containedCount = product.containedCount + 1 | ||
) else product | ||
} | ||
}, | ||
onAddClick = {}, | ||
onSubtractClick = {}, | ||
) | ||
} | ||
} | ||
|
||
// when: | ||
composeTestRule.onNodeWithContentDescription("shoppingProductAddButtonDescription") | ||
.performClick() | ||
|
||
// then: | ||
composeTestRule.onNodeWithContentDescription("shoppingCountBarDescription") | ||
.assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun λ΄κΈ΄_μνμ_μλμ΄_1κ°_λ―Έλ§μΌ_κ²½μ°_μλμ‘°μ _λ²νΌμ΄_μ¬λΌμ§κ³ _λ΄κΈ°λ²νΌμ΄_λ ΈμΆλλ€() { | ||
// given: | ||
var products by mutableStateOf( | ||
listOf( | ||
Product( | ||
id = 0L, | ||
name = "ν μ€νΈ1", | ||
imageUrl = "", | ||
price = 110L, | ||
containedCount = 1, | ||
) | ||
) | ||
) | ||
|
||
composeTestRule.apply { | ||
setContent { | ||
ShoppingListScreen( | ||
products = products, | ||
onShoppingCartClick = {}, | ||
onItemClick = {}, | ||
onPutClick = {}, | ||
onAddClick = {}, | ||
onSubtractClick = { selectedProductId -> | ||
products = products.map { product -> | ||
if (selectedProductId == product.id) product.copy( | ||
containedCount = product.containedCount - 1 | ||
) else product | ||
} | ||
}, | ||
) | ||
} | ||
} | ||
|
||
// when: | ||
composeTestRule.onNodeWithContentDescription("ShoppingCountBarSubtractIcon").performClick() | ||
|
||
// then: | ||
composeTestRule.onNodeWithContentDescription("ShoppingProductAddButton") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithContentDescription("shoppingCountBarDescription") | ||
.assertIsNotDisplayed() | ||
} | ||
|
||
@Test | ||
fun λ΄κΈ΄_μνμ_μλμ΄_2κ°μΌ_κ²½μ°_μΆκ°λ΄κΈ°_λ²νΌμ_λλ₯΄λ©΄_3κ°κ°_λλ€() { | ||
// given: | ||
var products by mutableStateOf( | ||
listOf( | ||
Product( | ||
id = 0L, | ||
name = "ν μ€νΈ1", | ||
imageUrl = "", | ||
price = 110L, | ||
containedCount = 2, | ||
) | ||
) | ||
) | ||
|
||
composeTestRule.apply { | ||
setContent { | ||
ShoppingListScreen( | ||
products = products, | ||
onShoppingCartClick = {}, | ||
onItemClick = {}, | ||
onPutClick = {}, | ||
onAddClick = { selectedProductId -> | ||
products = products.map { product -> | ||
if (selectedProductId == product.id) product.copy( | ||
containedCount = product.containedCount + 1 | ||
) else product | ||
} | ||
}, | ||
onSubtractClick = {}, | ||
) | ||
} | ||
} | ||
|
||
// when: | ||
composeTestRule.onNodeWithContentDescription("ShoppingCountBarAddIcon").performClick() | ||
|
||
// then: | ||
composeTestRule.onNodeWithText("3").isDisplayed() | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package nextstep.shoppingcart.shoppinglist.shoppinglist.component | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.assertIsNotDisplayed | ||
import androidx.compose.ui.test.assertTextEquals | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithContentDescription | ||
import nextstep.shoppingcart.ui.shoppinglist.component.ShoppingProductHeader | ||
import nextstep.shoppingcart.ui.shoppinglist.model.Product | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ShoppingProductHeaderTest { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. μ΄ ν μ€νΈ μλ리μ€μ λν΄ μ»΄ν¬λνΈμ Previewλ‘λ λ ΈμΆν΄λ³΄λ©΄ μ΄λ¨κΉμ? PreviewParameterλ₯Ό νμ©ν΄λ³Ό μ μμ κ² κ°μμ! |
||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun `0λ²_μνμ΄_μ₯λ°κ΅¬λμ_1κ°_μ΄μ_λ΄κ²¨μλ€λ©΄_κ°―μκ°_λ ΈμΆλλ€`() { | ||
// given: | ||
composeTestRule.apply { | ||
setContent { | ||
ShoppingProductHeader( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. HeaderλΌλ μ΄λ¦μ λ³΄ν΅ νμ΄μ§ μλ¨μ μλ μ 체μ μΈ λ¨Έλ¦ΏκΈμ μΌμ»¬μ λ μ¬μ©νκ³€ νλλ°μ, λ μ μ ν μ΄λ¦μ΄ μμκΉμ? |
||
product = Product( | ||
id = 0L, | ||
name = "μꡬλ₯΄νΈ", | ||
imageUrl = "", | ||
price = 500000000L, | ||
containedCount = 2, | ||
), | ||
onPutClick = {}, | ||
onAddClick = {}, | ||
onSubtractClick = {}, | ||
) | ||
} | ||
} | ||
|
||
// when: | ||
// then: | ||
composeTestRule.onNodeWithContentDescription("ShoppingProductAddButton") | ||
.assertIsNotDisplayed() | ||
composeTestRule.onNodeWithContentDescription("ShoppingCountBarTotalCount") | ||
.assertTextEquals("2") | ||
} | ||
|
||
@Test | ||
fun `0λ²_μνμ΄_μ₯λ°κ΅¬λμ_0κ°_λ΄κ²¨μλ€λ©΄_κ°―μ_μΆκ°_λ²νΌμ΄_λ ΈμΆλλ€`() { | ||
// given: | ||
composeTestRule.apply { | ||
setContent { | ||
ShoppingProductHeader( | ||
product = Product( | ||
id = 0L, | ||
name = "μꡬλ₯΄νΈ", | ||
imageUrl = "", | ||
price = 500000000L, | ||
containedCount = 0, | ||
), | ||
onPutClick = {}, | ||
onAddClick = {}, | ||
onSubtractClick = {}, | ||
) | ||
} | ||
} | ||
|
||
// when: | ||
// then: | ||
composeTestRule.onNodeWithContentDescription("ShoppingProductAddButton") | ||
.assertIsDisplayed() | ||
composeTestRule.onNodeWithContentDescription("shoppingCountBarDescription") | ||
.assertIsNotDisplayed() | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
κ°μ₯ ν° ν¨κ³ΌλΌκ³ νλ€λ©΄ Material λμμΈ κ°μ΄λμμ μ΄μΌκΈ°νλ λͺ μμ μΈ μν μ κ°μ₯ μ½κ² ꡬννλλ‘ λμμ£Όλ κ²μ΄λΌκ³ ν μ μκ² λ€μ.
https://m3.material.io/components/icon-buttons
μλ₯Ό λ€μ΄ Dividerλ λ΄λΆμμ Boxλ₯Ό ꡬννκ³ μλλ°μ, Boxλ₯Ό Modifierλ‘ μ‘°μνλ κ²κ³Ό λ€λ₯΄μ§ μλ€κ³ μκ°ν μ μμ§λ§
λͺ μμ μΌλ‘ λ μ΄μμμ λλλ λ°μ νμ©νλ μ»΄ν¬λνΈλ₯Ό νμ©νλ κ²μ λ μ νΈν©λλ€.