Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pururun committed Jul 25, 2024
1 parent ac826a8 commit 6ad7cd9
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class ConnectViewModelTest {
@Test
fun `onDisconnectClick should invoke disconnect on ConnectionProxy`() = runTest {
// Arrange
coEvery { mockConnectionProxy.disconnect() } returns true
coEvery { mockConnectionProxy.disconnect() } returns true.right()

// Act
viewModel.onDisconnectClick()
Expand All @@ -246,7 +246,7 @@ class ConnectViewModelTest {
@Test
fun `onReconnectClick should invoke reconnect on ConnectionProxy`() = runTest {
// Arrange
coEvery { mockConnectionProxy.reconnect() } returns true
coEvery { mockConnectionProxy.reconnect() } returns true.right()

// Act
viewModel.onReconnectClick()
Expand All @@ -270,7 +270,7 @@ class ConnectViewModelTest {
@Test
fun `onCancelClick should invoke disconnect on ConnectionProxy`() = runTest {
// Arrange
coEvery { mockConnectionProxy.disconnect() } returns true
coEvery { mockConnectionProxy.disconnect() } returns true.right()

// Act
viewModel.onCancelClick()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.mullvad.mullvadvpn.viewmodel

import app.cash.turbine.test
import arrow.core.right
import io.mockk.MockKAnnotations
import io.mockk.Runs
import io.mockk.coEvery
Expand Down Expand Up @@ -70,7 +71,7 @@ class DeviceRevokedViewModelTest {
@Test
fun `onGoToLoginClicked should invoke logout on AccountRepository`() {
// Arrange
coEvery { mockConnectionProxy.disconnect() } returns true
coEvery { mockConnectionProxy.disconnect() } returns true.right()
coEvery { mockedAccountRepository.logout() } just Runs

// Act
Expand All @@ -83,7 +84,7 @@ class DeviceRevokedViewModelTest {
@Test
fun `onGoToLoginClicked should invoke disconnect before logout when connected`() {
// Arrange
coEvery { mockConnectionProxy.disconnect() } returns true
coEvery { mockConnectionProxy.disconnect() } returns true.right()
coEvery { mockedAccountRepository.logout() } just Runs

// Act
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,9 @@ class LoginViewModelTest {

@Test
fun `clearAccountHistory should invoke clearAccountHistory on AccountRepository`() = runTest {
// Arrange
coEvery { mockedAccountRepository.clearAccountHistory() } returns Unit.right()

// Act, Assert
loginViewModel.clearAccountHistory()
coVerify { mockedAccountRepository.clearAccountHistory() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net.mullvad.mullvadvpn.viewmodel

import androidx.lifecycle.viewModelScope
import app.cash.turbine.test
import arrow.core.right
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
Expand Down Expand Up @@ -146,7 +147,7 @@ class OutOfTimeViewModelTest {
@Test
fun `onDisconnectClick should invoke disconnect on ConnectionProxy`() = runTest {
// Arrange
coEvery { mockConnectionProxy.disconnect() } returns true
coEvery { mockConnectionProxy.disconnect() } returns true.right()

// Act
viewModel.onDisconnectClick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package net.mullvad.mullvadvpn.viewmodel

import androidx.lifecycle.viewModelScope
import app.cash.turbine.test
import arrow.core.right
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
Expand Down Expand Up @@ -217,7 +218,7 @@ class WelcomeViewModelTest {
@Test
fun `when on disconnect click is called should call connection proxy disconnect`() = runTest {
// Arrange
coEvery { mockConnectionProxy.disconnect() } returns true
coEvery { mockConnectionProxy.disconnect() } returns true.right()

// Act
viewModel.onDisconnectClick()
Expand Down

0 comments on commit 6ad7cd9

Please sign in to comment.