This commit is contained in:
parent
bf6f1a917e
commit
f46f98cef0
@ -637,6 +637,49 @@ class RepositoryTest() {
|
||||
coVerify(exactly = 0) { api.update() }
|
||||
assertSame(false, response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun login() {
|
||||
coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true)
|
||||
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.login()
|
||||
}
|
||||
|
||||
coVerify(exactly = 1) { api.login() }
|
||||
assertSame(true, response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `login but response fails`() {
|
||||
coEvery { api.login() } returns SelfossModel.SuccessResponse(success = false)
|
||||
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.login()
|
||||
}
|
||||
|
||||
coVerify(exactly = 1) { api.login() }
|
||||
assertSame(false, response)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `login but without connection`() {
|
||||
coEvery { api.login() } returns SelfossModel.SuccessResponse(success = true)
|
||||
every { connectivityStatus.isNetworkConnected } returns MutableStateFlow(false)
|
||||
|
||||
val repository = Repository(api, appSettingsService, connectivityStatus, db)
|
||||
var response = false
|
||||
runBlocking {
|
||||
response = repository.login()
|
||||
}
|
||||
|
||||
coVerify(exactly = 0) { api.login() }
|
||||
assertSame(false, response)
|
||||
}
|
||||
}
|
||||
|
||||
fun generateTestDBItems(item : FakeItemParameters = FakeItemParameters()) : List<ITEM> {
|
||||
|
Loading…
Reference in New Issue
Block a user