Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
WIP: CalculatorTest.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Apr 29, 2022
1 parent 5f29be0 commit 46e8157
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class AmountInput<A : ComponentActivity>(
) {
fun enterNumber(
number: String,
onCalculator: Boolean = false
onCalculator: Boolean = false,
autoPressNonCalculator: Boolean = true,
) {
composeTestRule.waitForIdle()

Expand All @@ -32,7 +33,7 @@ class AmountInput<A : ComponentActivity>(
}
}

if (!onCalculator) {
if (!onCalculator && autoPressNonCalculator) {
clickSet()
}
}
Expand Down Expand Up @@ -78,7 +79,7 @@ class AmountInput<A : ComponentActivity>(
}

fun pressDivision() {
composeTestRule.onNodeWithTag("key_-")
composeTestRule.onNodeWithTag("key_/")
.performClick()
}

Expand All @@ -92,6 +93,11 @@ class AmountInput<A : ComponentActivity>(
.performClick()
}

fun pressCalcEqual() {
composeTestRule.onNodeWithTag("key_=")
.performClick()
}

fun clickCalcSet() {
composeTestRule.onNodeWithTag("calc_set")
.performClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,88 @@ class CalculatorTest : IvyComposeTest() {

@Test
fun setAmount_withAddition() {
onboarding.quickOnboarding()
mainBottomBar.clickAddFAB()
mainBottomBar.clickAddIncome()

amountInput.enterNumber(
number = "38.16",
autoPressNonCalculator = false
)
amountInput.clickCalculator()

//---------------------------

amountInput.pressPlus()
amountInput.enterNumber(
number = "80.74",
onCalculator = true
)

amountInput.clickCalcSet()
amountInput.clickSet()

transactionScreen.skipCategory()
transactionScreen.editTitle("Calc 2")
transactionScreen.clickAdd()

//----------------------------

//38.16 + 80.74 = 118.90
homeTab.assertBalance(
amount = "118",
amountDecimal = ".90"
)

homeTab.clickTransaction(
amount = "118.90",
title = "Calc 2"
)
}

@Test
fun calcAmount_viaDivision() {
onboarding.quickOnboarding()
mainBottomBar.clickAddFAB()
mainBottomBar.clickAddExpense()

amountInput.clickCalculator()

//---------------------------

amountInput.enterNumber(
number = "72.50",
onCalculator = true
)

amountInput.pressDivision()

amountInput.enterNumber(
number = "3",
onCalculator = true
)

amountInput.pressCalcEqual()

amountInput.clickCalcSet()
amountInput.clickSet()

transactionScreen.skipCategory()
transactionScreen.editTitle("Calc 3")

transactionScreen.clickAdd()
//----------------------------------------

//72.50 / 3 = 24.17
homeTab.assertBalance(
amount = "-24",
amountDecimal = ".17"
)

homeTab.clickTransaction(
amount = "24.17",
title = "Calc 3"
)
}

@Test
Expand All @@ -74,7 +150,7 @@ class CalculatorTest : IvyComposeTest() {
}

@Test
fun calcComplexExpression() {
fun calcAmount_complexExpression() {

}
}

0 comments on commit 46e8157

Please sign in to comment.