Skip to content

Commit

Permalink
Fix VoucherRedeemer test issue
Browse files Browse the repository at this point in the history
  • Loading branch information
sabercodic committed Oct 12, 2023
1 parent 1a443f1 commit 1eadcac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class VoucherDialogViewModel(
private val vmState = MutableStateFlow<VoucherDialogState>(VoucherDialogState.Default)
private val voucherInput = MutableStateFlow(LoginUiState.INITIAL.accountNumberInput)

private lateinit var voucherRedeemer: VoucherRedeemer
lateinit var voucherRedeemer: VoucherRedeemer
private val _shared: SharedFlow<ServiceConnectionContainer> =
serviceConnectionManager.connectionState
.flatMapLatest { state ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,18 @@ class VoucherDialogViewModelTest {
}

@Test
fun test_submit_invalid_voucher() = runTest {
val voucher = DUMMY_VALID_VOUCHER
val dummyStringResource = DUMMY_STRING_RESOURCE
// Arrange
every { mockResources.getString(any()) } returns dummyStringResource
coEvery { mockVoucherRedeemer.submit(voucher) } returns mockVoucherSubmissionErrorResult
// Act, Assert
viewModel.onRedeem(voucher)
coVerify(exactly = 1) { mockVoucherRedeemer.submit(voucher) }
}
fun test_submit_invalid_voucher() =
runTest(testCoroutineRule.testDispatcher) {
val voucher = DUMMY_VALID_VOUCHER
val dummyStringResource = DUMMY_STRING_RESOURCE
// Arrange
viewModel.voucherRedeemer = mockVoucherRedeemer
every { mockResources.getString(any()) } returns dummyStringResource
coEvery { mockVoucherRedeemer.submit(voucher) } returns mockVoucherSubmissionErrorResult
// Act, Assert
viewModel.onRedeem(voucher)
coVerify(exactly = 1) { mockVoucherRedeemer.submit(voucher) }
}

companion object {
private const val CACHE_EXTENSION_CLASS = "net.mullvad.mullvadvpn.util.CacheExtensionsKt"
Expand Down

0 comments on commit 1eadcac

Please sign in to comment.