|
1 | 1 | package br.com.mob1st.features.finances.impl.ui.category.navigation
|
2 | 2 |
|
| 3 | +import br.com.mob1st.features.finances.impl.domain.entities.Category |
3 | 4 | import br.com.mob1st.features.finances.impl.domain.entities.CategoryDefaultValues
|
| 5 | +import br.com.mob1st.features.finances.impl.domain.entities.GetCategoryIntent |
4 | 6 | import br.com.mob1st.features.finances.impl.domain.values.category
|
5 | 7 | import io.kotest.property.Arb
|
6 | 8 | import io.kotest.property.arbitrary.bind
|
| 9 | +import io.kotest.property.arbitrary.map |
7 | 10 | import io.kotest.property.arbitrary.next
|
8 | 11 | import io.kotest.property.arbitrary.string
|
9 | 12 | import org.junit.jupiter.api.Test
|
@@ -46,4 +49,44 @@ class CategoryDetailArgsTest {
|
46 | 49 | )
|
47 | 50 | assertEquals(expected, actual)
|
48 | 51 | }
|
| 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 | + } |
49 | 92 | }
|
0 commit comments