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

Commit

Permalink
Implement CalculatorTest.kt
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Apr 29, 2022
1 parent 46e8157 commit d21063b
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CalculatorTest : IvyComposeTest() {


@Test
fun calcAmount_viaExtraction() {
fun calcAmount_viaExtraction() = testWithRetry {
onboarding.quickOnboarding()
mainBottomBar.clickAddFAB()
mainBottomBar.clickAddExpense()
Expand Down Expand Up @@ -46,6 +46,8 @@ class CalculatorTest : IvyComposeTest() {

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

homeTab.dismissPrompt()

//21 - 3.52 = 17.48
homeTab.assertBalance(
amount = "-17",
Expand All @@ -59,7 +61,7 @@ class CalculatorTest : IvyComposeTest() {
}

@Test
fun setAmount_withAddition() {
fun setAmount_withAddition() = testWithRetry {
onboarding.quickOnboarding()
mainBottomBar.clickAddFAB()
mainBottomBar.clickAddIncome()
Expand Down Expand Up @@ -87,6 +89,8 @@ class CalculatorTest : IvyComposeTest() {

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

homeTab.dismissPrompt()

//38.16 + 80.74 = 118.90
homeTab.assertBalance(
amount = "118",
Expand All @@ -100,7 +104,7 @@ class CalculatorTest : IvyComposeTest() {
}

@Test
fun calcAmount_viaDivision() {
fun calcAmount_viaDivision() = testWithRetry {
onboarding.quickOnboarding()
mainBottomBar.clickAddFAB()
mainBottomBar.clickAddExpense()
Expand Down Expand Up @@ -132,6 +136,8 @@ class CalculatorTest : IvyComposeTest() {
transactionScreen.clickAdd()
//----------------------------------------

homeTab.dismissPrompt()

//72.50 / 3 = 24.17
homeTab.assertBalance(
amount = "-24",
Expand All @@ -145,12 +151,100 @@ class CalculatorTest : IvyComposeTest() {
}

@Test
fun setAmount_withMultiplication() {
fun setAmount_withMultiplication_percentDiscount() = testWithRetry {
onboarding.quickOnboarding()
mainBottomBar.clickAddFAB()
mainBottomBar.clickAddIncome()

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

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

amountInput.pressMultiplication()

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

amountInput.clickCalcSet()
amountInput.clickSet()

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

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

homeTab.dismissPrompt()

//83,000.50 * 0.9 = 74,700.45
homeTab.assertBalance(
amount = "74,700",
amountDecimal = ".45"
)

homeTab.clickTransaction(
amount = "74,700.45",
title = "Calc 4"
)
}

@Test
fun calcAmount_complexExpression() {
fun calcAmount_complexExpression() = testWithRetry {
onboarding.quickOnboarding()
mainBottomBar.clickAddFAB()
mainBottomBar.clickAddExpense()

amountInput.clickCalculator()
//---------------------------

//(523.90+16.7-4+2345.88)*0.9*0.7

amountInput.pressLeftBracket()
amountInput.enterNumber("523.90", onCalculator = true)
amountInput.pressPlus()
amountInput.enterNumber("16.7", onCalculator = true)
amountInput.pressMinus()
amountInput.enterNumber("4", onCalculator = true)
amountInput.pressPlus()
amountInput.enterNumber("2345.88", onCalculator = true)
amountInput.pressRightBracket()
amountInput.pressMultiplication()
amountInput.enterNumber("0.9", onCalculator = true)
amountInput.pressMultiplication()
amountInput.enterNumber("0.7", onCalculator = true)


//+ 10 =
amountInput.pressCalcEqual()
amountInput.pressPlus()
amountInput.enterNumber("10", onCalculator = true)
amountInput.pressCalcEqual()

amountInput.clickCalcSet()
amountInput.clickSet()
transactionScreen.skipCategory()
transactionScreen.editTitle("Calc Complex")
transactionScreen.clickAdd()

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

homeTab.dismissPrompt()

//(523.90+16.7-4+2345.88)*0.9*0.7 = 1815.9624 ; 1815.9624 + 10; = 1,825.96
homeTab.assertBalance(
amount = "-1,825",
amountDecimal = ".96"
)

homeTab.clickTransaction(
amount = "1,825.96",
title = "Calc Complex"
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class PieChartTest : IvyComposeTest() {
private val pieChartScreen = PieChartScreen(composeTestRule)

@Test
fun expensePieChart_realistic() {
fun expensePieChart_realistic() = testWithRetry {
onboarding.quickOnboarding()

transactionFlow.addExpense(
Expand Down Expand Up @@ -51,7 +51,7 @@ class PieChartTest : IvyComposeTest() {
}

@Test
fun expensePieChart_empty() {
fun expensePieChart_empty() = testWithRetry {
onboarding.quickOnboarding()

transactionFlow.addIncome(
Expand All @@ -71,7 +71,7 @@ class PieChartTest : IvyComposeTest() {
}

@Test
fun expensePieChart_oneTrn() {
fun expensePieChart_oneTrn() = testWithRetry {
onboarding.quickOnboarding()

transactionFlow.addExpense(
Expand All @@ -91,7 +91,7 @@ class PieChartTest : IvyComposeTest() {
}

@Test
fun incomePieChart_realistic() {
fun incomePieChart_realistic() = testWithRetry {
onboarding.quickOnboarding()

//To ensure that the code filters expenses
Expand Down Expand Up @@ -123,7 +123,7 @@ class PieChartTest : IvyComposeTest() {
}

@Test
fun incomePieChart_empty() {
fun incomePieChart_empty() = testWithRetry {
onboarding.quickOnboarding()

transactionFlow.addExpense(
Expand Down

0 comments on commit d21063b

Please sign in to comment.