Skip to content

Commit

Permalink
Add test for UpdateProfileUseCaseImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
Geanik committed Oct 19, 2023
1 parent 7cbf581 commit f0d8d88
Showing 1 changed file with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.hieuwu.groceriesstore.domain.usecases.impl

import com.hieuwu.groceriesstore.data.repository.UserRepository
import com.hieuwu.groceriesstore.domain.usecases.UpdateProfileUseCase
import java.util.*
import kotlinx.coroutines.runBlocking
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.Mock
import org.mockito.junit.MockitoJUnitRunner
import org.mockito.kotlin.verify

@RunWith(MockitoJUnitRunner::class)
class UpdateProfileUseCaseImplTest {

@Mock
lateinit var mockedUserRepository: UserRepository
private lateinit var testee: UpdateProfileUseCaseImpl

@Before
fun setUp() {
testee = UpdateProfileUseCaseImpl(userRepository = mockedUserRepository)
}

@Test
fun whenExecute_thenCallUserRepository() {
val input =
UpdateProfileUseCase.Input(
userId = UUID.randomUUID().toString(),
name = UUID.randomUUID().toString(),
email = UUID.randomUUID().toString(),
phone = UUID.randomUUID().toString(),
address = UUID.randomUUID().toString(),
)

runBlocking {
testee.execute(input)

verify(mockedUserRepository)
.updateUserProfile(
userId = input.userId,
name = input.name,
email = input.email,
phone = input.phone,
address = input.address,
)
}
}
}

0 comments on commit f0d8d88

Please sign in to comment.