Skip to content

Commit

Permalink
[#21] Rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
blyscuit committed Dec 20, 2022
1 parent ebb18c1 commit 2422f15
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.nimblehq.blisskmmic.data.model

import co.nimblehq.blisskmmic.domain.model.Survey
import co.nimblehq.blisskmmic.domain.model.User
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -11,10 +12,9 @@ data class UserApiModel(
val email: String,
val name: String,
@SerialName("avatar_url") val avatarUrl: String
) {
)

fun toUser(): User = User(
name,
avatarUrl
)
}
fun UserApiModel.toUser() = User(
name,
avatarUrl
)
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package co.nimblehq.blisskmmic.data.repository

import co.nimblehq.blisskmmic.data.model.toUser
import co.nimblehq.blisskmmic.data.network.datasource.NetworkDataSource
import co.nimblehq.blisskmmic.data.network.target.UserProfileTargetType
import co.nimblehq.blisskmmic.domain.model.User
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class AuthenticationRepositoryTest: TestsWithMocks() {
}

@Test
fun `When calling hasCachedToken, it returns true when there is a token`() = runTest {
fun `When calling hasCachedToken- it returns true when there is a token`() = runTest {
mocker.every {
localDataSource.getToken()
} returns flowOf(tokenDB)
Expand All @@ -132,7 +132,7 @@ class AuthenticationRepositoryTest: TestsWithMocks() {
}

@Test
fun `When calling hasCachedToken, it returns false when there is an error`() = runTest {
fun `When calling hasCachedToken- it returns false when there is an error`() = runTest {
mocker.every {
localDataSource.getToken()
} returns flow { error("No token") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CheckLoginUseCaseTest {
}

@Test
fun `When calling check with response true, it returns true`() = runTest {
fun `When calling check with response true- it returns true`() = runTest {
mocker.every {
authenticationRepository.hasCachedToken()
} returns flowOf(true)
Expand All @@ -40,7 +40,7 @@ class CheckLoginUseCaseTest {
}

@Test
fun `When calling check with response false, it returns false`() = runTest {
fun `When calling check with response false- it returns false`() = runTest {
mocker.every {
authenticationRepository.hasCachedToken()
} returns flowOf(false)
Expand All @@ -53,7 +53,7 @@ class CheckLoginUseCaseTest {
}

@Test
fun `When calling check with a failure response, it returns correct error`() = runTest {
fun `When calling check with a failure response- it returns correct error`() = runTest {
mocker.every {
authenticationRepository.hasCachedToken()
} returns flow { error("Fail") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import kotlin.test.assertTrue
class StringRegexTest {

@Test
fun `When calling isValidEmail emails, it returns correct validity`() {
fun `When calling isValidEmail emails- it returns correct validity`() {
"a@a.co.uk".isValidEmail() shouldBe true
"ab.cd@abc.org".isValidEmail() shouldBe true
"a@a.com".isValidEmail() shouldBe true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class LoginViewModelTest : TestsWithMocks() {
}

@Test
fun `When calling login with an invalid email, it changes viewState to error`() = runTest {
fun `When calling login with an invalid email- it changes viewState to error`() = runTest {
loginViewModel.login("invalid", password)

val result = loginViewModel
Expand All @@ -88,7 +88,7 @@ class LoginViewModelTest : TestsWithMocks() {
}

@Test
fun `When calling login with an empty password, it changes viewState to error`() = runTest {
fun `When calling login with an empty password- it changes viewState to error`() = runTest {
loginViewModel.login(email, "")

val result = loginViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class SplashViewModelTest : TestsWithMocks() {
}

@Test
fun `When calling checkLogin with true response, it changes viewState correctly`() = runTest {
fun `When calling checkLogin with true response- it changes viewState correctly`() = runTest {
mocker.every {
checkLoginUseCase()
} returns flowOf(true)
Expand All @@ -63,7 +63,7 @@ class SplashViewModelTest : TestsWithMocks() {
}

@Test
fun `When calling checkLogin with false response, it changes viewState correctly`() = runTest {
fun `When calling checkLogin with false response- it changes viewState correctly`() = runTest {
mocker.every {
checkLoginUseCase()
} returns flow{
Expand All @@ -85,7 +85,7 @@ class SplashViewModelTest : TestsWithMocks() {
}

@Test
fun `When calling checkLogin with faliure response, it changes viewState correctly`() = runTest {
fun `When calling checkLogin with faliure response- it changes viewState correctly`() = runTest {
mocker.every {
checkLoginUseCase()
} returns flow {
Expand Down

0 comments on commit 2422f15

Please sign in to comment.