Skip to content

Commit 1a3f41b

Browse files
committed
Fix unit tests
1 parent 9558aea commit 1a3f41b

File tree

4 files changed

+32
-18
lines changed

4 files changed

+32
-18
lines changed

src/commonMain/kotlin/com/yesferal/hornsapp/core/domain/entity/render/DataRender.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ package com.yesferal.hornsapp.core.domain.entity.render
44
import com.yesferal.hornsapp.core.domain.entity.util.LocalizedString
55

66
class DataRender(
7-
val key: String,
7+
val key: String?,
88
val title: LocalizedString?,
99
val subtitle: LocalizedString?,
1010
val description: LocalizedString?,
@@ -15,6 +15,6 @@ class DataRender(
1515
val textColor: String?,
1616
val backgroundColor: String?,
1717
val elevation: Boolean?,
18-
val ctas: List<CtaRender>,
18+
val ctas: List<CtaRender>?,
1919
val visibility: Boolean?,
2020
)

src/jvmTest/kotlin/com/yesferal/hornsapp/core/domain/entity/render/ViewRenderTest.kt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class ViewRenderTest : MockitoTest {
1717
@Test
1818
fun givenViewRender_WhenThereIsNotData_ThenShouldRenderTrue() {
1919
// Given
20-
val key = ViewRender.Type.NEWEST_FRAGMENT
20+
val key = ViewRender.Type.CARD_VIEW
2121
val data = null
2222

2323
// When
@@ -30,7 +30,7 @@ class ViewRenderTest : MockitoTest {
3030
@Test
3131
fun givenViewRender_WhenThereIsNotVisibility_ThenShouldRenderTrue() {
3232
// Given
33-
val key = ViewRender.Type.NEWEST_FRAGMENT
33+
val key = ViewRender.Type.CARD_VIEW
3434
val data = DataRender(
3535
null,
3636
null,
@@ -40,7 +40,11 @@ class ViewRenderTest : MockitoTest {
4040
null,
4141
null,
4242
null,
43-
visibility = null
43+
null,
44+
visibility = null,
45+
backgroundColor = null,
46+
elevation = null,
47+
ctas = null,
4448
)
4549

4650
// When
@@ -53,7 +57,7 @@ class ViewRenderTest : MockitoTest {
5357
@Test
5458
fun givenViewRender_WhenThereIsTrueVisibility_ThenShouldRenderTrue() {
5559
// Given
56-
val key = ViewRender.Type.NEWEST_FRAGMENT
60+
val key = ViewRender.Type.CARD_VIEW
5761
val data = DataRender(
5862
null,
5963
null,
@@ -63,7 +67,11 @@ class ViewRenderTest : MockitoTest {
6367
null,
6468
null,
6569
null,
66-
visibility = true
70+
null,
71+
visibility = true,
72+
backgroundColor = null,
73+
elevation = null,
74+
ctas = null,
6775
)
6876

6977
// When
@@ -76,7 +84,7 @@ class ViewRenderTest : MockitoTest {
7684
@Test
7785
fun givenViewRender_WhenThereIsFalseVisibility_ThenShouldRenderTrue() {
7886
// Given
79-
val key = ViewRender.Type.NEWEST_FRAGMENT
87+
val key = ViewRender.Type.CARD_VIEW
8088
val data = DataRender(
8189
null,
8290
null,
@@ -86,7 +94,11 @@ class ViewRenderTest : MockitoTest {
8694
null,
8795
null,
8896
null,
89-
visibility = false
97+
null,
98+
visibility = false,
99+
backgroundColor = null,
100+
elevation = null,
101+
ctas = null,
90102
)
91103

92104
// When

src/jvmTest/kotlin/com/yesferal/hornsapp/core/domain/navigator/NavigatorTest.kt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
/* Copyright © 2021 HornsApp. All rights reserved. */
22
package com.yesferal.hornsapp.core.domain.navigator
33

4+
import com.yesferal.hornsapp.core.domain.entity.render.ScreenRender
45
import org.junit.Assert
56
import org.junit.Test
67

@@ -19,14 +20,14 @@ class NavigatorTest {
1920
fun given_aDirectionBuilder_withData_ThenGetDataFromResult() {
2021
// Given
2122
val directionBuilder = Navigator.Builder()
22-
.to(ScreenType.HOME)
23+
.to(ScreenRender.Type.HOME_SCREEN)
2324
.with(parameters)
2425

2526
// When
2627
val result = directionBuilder.build()
2728

2829
// Then
29-
Assert.assertEquals(ScreenType.HOME, result.to)
30+
Assert.assertEquals(ScreenRender.Type.HOME_SCREEN, result.to)
3031
Assert.assertEquals(parameters, result.parameters)
3132
Assert.assertEquals(parameters.getString("id"), result.parameters?.getString("id"))
3233
}
@@ -35,25 +36,25 @@ class NavigatorTest {
3536
fun given_aDirectionBuilder_withStringOrigin_ThenGetSameOriginFromResult() {
3637
// Given
3738
val directionBuilder = Navigator.Builder()
38-
.to("HOME")
39+
.to("HOME_SCREEN")
3940

4041
// When
4142
val result = directionBuilder.build()
4243

4344
// Then
44-
Assert.assertEquals(ScreenType.HOME, result.to)
45+
Assert.assertEquals(ScreenRender.Type.HOME_SCREEN, result.to)
4546
}
4647

4748
@Test
4849
fun given_aDirectionBuilder_withScreenTypeOrigin_ThenGetSameOriginFromResult() {
4950
// Given
5051
val directionBuilder = Navigator.Builder()
51-
.to(ScreenType.HOME)
52+
.to(ScreenRender.Type.HOME_SCREEN)
5253

5354
// When
5455
val result = directionBuilder.build()
5556

5657
// Then
57-
Assert.assertEquals(ScreenType.HOME, result.to)
58+
Assert.assertEquals(ScreenRender.Type.HOME_SCREEN, result.to)
5859
}
5960
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
/* Copyright © 2021 HornsApp. All rights reserved. */
22
package com.yesferal.hornsapp.core.domain.navigator
33

4+
import com.yesferal.hornsapp.core.domain.entity.render.ScreenRender
45
import org.junit.Assert
56
import org.junit.Test
67

78
/**
8-
* This class will test [ScreenType]
9+
* This class will test [ScreenRender.Type]
910
*
1011
* @author Yesferal
1112
*/
1213
class ScreenTypeTest {
1314
@Test
1415
fun givenAnScreenType_WhenParseAsDirection_ThenResultShouldContainsType() {
1516
// Given
16-
val screenType = ScreenType.HOME
17+
val screenType = ScreenRender.Type.HOME_SCREEN
1718

1819
// When
1920
val result = Navigator.Builder().to(screenType).build()
2021

2122
// Then
22-
Assert.assertEquals(ScreenType.HOME, result.to)
23+
Assert.assertEquals(ScreenRender.Type.HOME_SCREEN, result.to)
2324
}
2425
}

0 commit comments

Comments
 (0)