From 34881931bee15fbcda977c3a6cd449d10289b7d9 Mon Sep 17 00:00:00 2001 From: Ouday Date: Sat, 16 Dec 2023 16:53:59 +0100 Subject: [PATCH] Fix Github action --- .../cryptowalletsample/BillViewModelTest.kt | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/src/test/java/com/ouday/cryptowalletsample/BillViewModelTest.kt b/app/src/test/java/com/ouday/cryptowalletsample/BillViewModelTest.kt index 6842c34..2ac3cbf 100644 --- a/app/src/test/java/com/ouday/cryptowalletsample/BillViewModelTest.kt +++ b/app/src/test/java/com/ouday/cryptowalletsample/BillViewModelTest.kt @@ -51,26 +51,26 @@ class BillViewModelTest { } @Test - fun `triggerFetchBills emits loading and then success state`() = testScope.runTest { - val historyList = listOf(History("2023-01-01", 100.0, true)) - val billList = listOf(Bill(1, "Electricity", "icon_url", historyList)) + fun `triggerFetchBills emits loading and then success state`() = runTest { + val history = listOf( + History("2022-02-24", 313.08, true), + ) + val bills = listOf(Bill(1, "Electricity Bill", "electricity.svg", history)) + `when`(billUseCase.getBills()).thenReturn(flowOf(bills)) - `when`(billUseCase.getBills()).thenReturn(flowOf(billList)) - - val collectedStates = mutableListOf>>() val job = launch { - viewModel.bills.collect { collectedStates.add(it) } + viewModel.triggerFetchBills() } - viewModel.triggerFetchBills() - val states = viewModel.bills.take(2).toList() Assert.assertTrue("First state should be Loading", states[0] is FlowState.Loading) advanceUntilIdle() - advanceTimeBy(1000) - Assert.assertTrue("Second state should be Success", states.size > 1 && states[1] is FlowState.Success && (states[1] as FlowState.Success).data == billList) + Assert.assertTrue( + "Second state should be Success", + states[1] is FlowState.Success && (states[1] as FlowState.Success).data == bills + ) job.cancel() }