Skip to content

Commit f3d4440

Browse files
committed
unit test to intent method
1 parent 060cb96 commit f3d4440

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

Diff for: features/finances/impl/src/test/kotlin/br/com/mob1st/features/finances/impl/ui/category/navigation/CategoryDetailArgsTest.kt

+43
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package br.com.mob1st.features.finances.impl.ui.category.navigation
22

3+
import br.com.mob1st.features.finances.impl.domain.entities.Category
34
import br.com.mob1st.features.finances.impl.domain.entities.CategoryDefaultValues
5+
import br.com.mob1st.features.finances.impl.domain.entities.GetCategoryIntent
46
import br.com.mob1st.features.finances.impl.domain.values.category
57
import io.kotest.property.Arb
68
import io.kotest.property.arbitrary.bind
9+
import io.kotest.property.arbitrary.map
710
import io.kotest.property.arbitrary.next
811
import io.kotest.property.arbitrary.string
912
import org.junit.jupiter.api.Test
@@ -46,4 +49,44 @@ class CategoryDetailArgsTest {
4649
)
4750
assertEquals(expected, actual)
4851
}
52+
53+
@Test
54+
fun `GIVEN a edit args WHEN map to domain intent THEN assert it is edit`() {
55+
// Given
56+
val intent = Arb.bind<CategoryDetailArgs.Intent.Edit>().next()
57+
val args = Arb.bind<CategoryDetailArgs>().map {
58+
it.copy(intent = intent)
59+
}.next()
60+
61+
// When
62+
val actual = args.toIntent()
63+
64+
// Then
65+
val expected = GetCategoryIntent.Edit(
66+
id = Category.Id(intent.id),
67+
name = args.name,
68+
)
69+
assertEquals(expected, actual)
70+
}
71+
72+
@Test
73+
fun `GIVEN a create args WHEN map to domain intent THEN assert it is create`() {
74+
// Given
75+
val args = Arb.bind<CategoryDetailArgs>().map {
76+
it.copy(intent = CategoryDetailArgs.Intent.Create)
77+
}.next()
78+
79+
// When
80+
val actual = args.toIntent()
81+
82+
// Then
83+
val expected = GetCategoryIntent.Create(
84+
name = args.name,
85+
defaultValues = CategoryDefaultValues(
86+
isExpense = args.isExpense,
87+
recurrenceType = args.recurrenceType,
88+
),
89+
)
90+
assertEquals(expected, actual)
91+
}
4992
}

0 commit comments

Comments
 (0)