-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break up
InputIconCardTest
into InputMatrixTest
and `InputSequent…
…ialTest`
- Loading branch information
1 parent
99021df
commit 6c342d7
Showing
2 changed files
with
117 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
.../desktopTest/kotlin/org/hisp/dhis/mobile/ui/designsystem/component/InputSequentialTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
package org.hisp.dhis.mobile.ui.designsystem.component | ||
|
||
import androidx.compose.ui.graphics.Color | ||
import androidx.compose.ui.test.assertAll | ||
import androidx.compose.ui.test.isEnabled | ||
import androidx.compose.ui.test.isNotEnabled | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onAllNodesWithTag | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import org.hisp.dhis.mobile.ui.designsystem.component.internal.IconCardData | ||
import org.hisp.dhis.mobile.ui.designsystem.theme.SurfaceColor | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class InputSequentialTest { | ||
|
||
@get:Rule | ||
val rule = createComposeRule() | ||
|
||
private val data = listOf( | ||
IconCardData( | ||
uid = "7e0cb105-c276-4f12-9f56-a26af8314121", | ||
label = "Stethoscope", | ||
iconRes = "dhis2_stethoscope_positive", | ||
iconTint = Color(0xFFFF8400), | ||
), | ||
IconCardData( | ||
uid = "72269f6b-6b99-4d2e-a667-09f20c2097e0", | ||
label = "Medicines", | ||
iconRes = "dhis2_medicines_positive", | ||
iconTint = Color(0xFFEB0085), | ||
), | ||
IconCardData( | ||
uid = "37b81748-e9b4-4f74-a50a-59b945e54aa4", | ||
label = "Sayana press", | ||
iconRes = "dhis2_sayana_press_positive", | ||
iconTint = Color(0xFF1FDB00), | ||
), | ||
) | ||
|
||
@Test | ||
fun shouldNotAllowSequentialUserInputWhenDisabled() { | ||
rule.setContent { | ||
InputSequential( | ||
title = "Label", | ||
testTag = "TEST", | ||
data = data, | ||
selectedData = null, | ||
state = InputShellState.DISABLED, | ||
onSelectionChanged = { | ||
// no-op | ||
}, | ||
) | ||
} | ||
rule.onNodeWithTag("ICON_CARD_INPUT_SEQUENTIAL_TEST").assertExists() | ||
rule.onAllNodesWithTag("SEQUENTIAL_ICON_CARD_TEST").assertAll(isNotEnabled()) | ||
} | ||
|
||
@Test | ||
fun shouldAllowSequentialUserInputWhenEnabled() { | ||
rule.setContent { | ||
InputSequential( | ||
title = "Label", | ||
testTag = "TEST", | ||
data = data, | ||
selectedData = null, | ||
state = InputShellState.UNFOCUSED, | ||
onSelectionChanged = { | ||
// no-op | ||
}, | ||
) | ||
} | ||
rule.onNodeWithTag("ICON_CARD_INPUT_SEQUENTIAL_TEST").assertExists() | ||
rule.onAllNodesWithTag("SEQUENTIAL_ICON_CARD_TEST").assertAll(isEnabled()) | ||
} | ||
|
||
@Test | ||
fun shouldShowSequentialLegendCorrectly() { | ||
rule.setContent { | ||
InputMatrix( | ||
title = "Label", | ||
testTag = "TEST", | ||
data = data, | ||
selectedData = null, | ||
itemCount = 2, | ||
state = InputShellState.UNFOCUSED, | ||
legendData = LegendData(SurfaceColor.CustomGreen, "Legend"), | ||
onSelectionChanged = { | ||
// no-op | ||
}, | ||
) | ||
} | ||
|
||
rule.onNodeWithTag("ICON_CARDS_INPUT_TEST_LEGEND").assertExists() | ||
} | ||
|
||
@Test | ||
fun shouldShowSequentialSupportingTextCorrectly() { | ||
rule.setContent { | ||
InputSequential( | ||
title = "Label", | ||
testTag = "TEST", | ||
data = data, | ||
selectedData = null, | ||
state = InputShellState.UNFOCUSED, | ||
supportingText = listOf(SupportingTextData("Supporting text", SupportingTextState.DEFAULT)), | ||
onSelectionChanged = { | ||
// no-op | ||
}, | ||
) | ||
} | ||
|
||
rule.onNodeWithTag("ICON_CARDS_INPUT_TEST_SUPPORTING_TEXT").assertExists() | ||
} | ||
} |