-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
263 additions
and
29 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
65 changes: 65 additions & 0 deletions
65
jobisdesignsystemv2/src/androidTest/java/team/returm/jobisdesignsystemv2/JobisButtonTest.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,65 @@ | ||
package team.returm.jobisdesignsystemv2 | ||
|
||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.platform.testTag | ||
import androidx.compose.ui.test.assertHasClickAction | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.performClick | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import team.returm.jobisdesignsystemv2.button.JobisButton | ||
|
||
private const val BTN_TEST_TAG = "ButtonTest" | ||
|
||
/** | ||
* Verifies that the button appears on the display and that a click action is performed | ||
* assertHasClickAction cannot be used because JobisButton does not use the button's onClick | ||
* @see JobisButton | ||
* @see assertHasClickAction | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class JobisButtonTest { | ||
@get:Rule | ||
val composeRule = createComposeRule() | ||
private var clicked = 0 | ||
|
||
@Test | ||
fun enabledJobisButtonTest() { | ||
composeRule.setContent { | ||
JobisButton( | ||
modifier = Modifier.testTag(BTN_TEST_TAG), | ||
text = BTN_TEST_TAG, | ||
onClick = { clicked++ }, | ||
enabled = false, | ||
) | ||
} | ||
composeRule | ||
.onNodeWithTag(BTN_TEST_TAG) | ||
.assertIsDisplayed() | ||
.performClick() | ||
|
||
composeRule.runOnIdle { assert(clicked == 0) } | ||
} | ||
|
||
@Test | ||
fun jobisButtonTest() { | ||
composeRule.setContent { | ||
JobisButton( | ||
modifier = Modifier.testTag(BTN_TEST_TAG), | ||
text = BTN_TEST_TAG, | ||
onClick = { clicked++ }, | ||
enabled = true, | ||
) | ||
} | ||
composeRule | ||
.onNodeWithTag(BTN_TEST_TAG) | ||
.assertIsDisplayed() | ||
.performClick() | ||
|
||
composeRule.runOnIdle { assert(clicked == 1) } | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
...designsystemv2/src/androidTest/java/team/returm/jobisdesignsystemv2/JobisTextFieldTest.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,73 @@ | ||
package team.returm.jobisdesignsystemv2 | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.runtime.LaunchedEffect | ||
import androidx.compose.runtime.getValue | ||
import androidx.compose.runtime.mutableStateOf | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.runtime.setValue | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import team.returm.jobisdesignsystemv2.textfield.DescriptionType | ||
import team.returm.jobisdesignsystemv2.textfield.JobisTextField | ||
|
||
private const val TEXT_FIELD_TEST_TAG = "TextTest" | ||
|
||
/** | ||
* Verify that the DescriptionType of the textfield is properly changed and hint and title | ||
* @see JobisTextField | ||
* @see DescriptionType | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class JobisTextFieldTest { | ||
@get:Rule | ||
val composeRule = createComposeRule() | ||
|
||
@Test | ||
fun jobisTextFieldTest() { | ||
val hint = "hint" | ||
val checkDescription = "check" | ||
val errorDescription = "error" | ||
val informationDescription = "information" | ||
var type: DescriptionType = DescriptionType.Information | ||
composeRule.setContent { | ||
var text by remember { mutableStateOf("") } | ||
LaunchedEffect(key1 = text) { | ||
type = when (text.length) { | ||
in 0 until 8 -> DescriptionType.Error | ||
else -> DescriptionType.Check | ||
} | ||
} | ||
JobisTextField( | ||
title = TEXT_FIELD_TEST_TAG, | ||
value = { text }, | ||
hint = hint, | ||
onValueChange = { }, | ||
checkDescription = checkDescription, | ||
errorDescription = errorDescription, | ||
informationDescription = informationDescription, | ||
descriptionType = type, | ||
showDescription = { true }, | ||
modifier = Modifier.clickable { text = "text" } | ||
) | ||
} | ||
|
||
val titleTest = composeRule.onNodeWithText(TEXT_FIELD_TEST_TAG) | ||
titleTest.assertIsDisplayed() | ||
|
||
val hintTest = composeRule.onNodeWithText(hint) | ||
hintTest.assertIsDisplayed() | ||
|
||
val descriptionTest = composeRule.onNodeWithText(TEXT_FIELD_TEST_TAG) | ||
descriptionTest.performClick() | ||
|
||
composeRule.runOnIdle { assert(type == DescriptionType.Error) } | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
jobisdesignsystemv2/src/androidTest/java/team/returm/jobisdesignsystemv2/JobisTextTest.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,42 @@ | ||
package team.returm.jobisdesignsystemv2 | ||
|
||
import androidx.compose.foundation.clickable | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import androidx.test.ext.junit.runners.AndroidJUnit4 | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import team.returm.jobisdesignsystemv2.foundation.JobisTypography | ||
import team.returm.jobisdesignsystemv2.text.JobisText | ||
|
||
private const val TEXT_TEST_TAG = "TextTest" | ||
|
||
/** | ||
* Verifies that text appears on the display and that styles are applied correctly | ||
* @see JobisText | ||
*/ | ||
@RunWith(AndroidJUnit4::class) | ||
class JobisTextTest { | ||
@get:Rule | ||
val composeRule = createComposeRule() | ||
private var style = JobisTypography.Body | ||
|
||
@Test | ||
fun jobisTextTest() { | ||
composeRule.setContent { | ||
JobisText( | ||
text = TEXT_TEST_TAG, | ||
style = style, | ||
modifier = Modifier.clickable { style = JobisTypography.Caption } | ||
) | ||
} | ||
val test = composeRule.onNodeWithText(TEXT_TEST_TAG).assertIsDisplayed() | ||
test.performClick() | ||
|
||
composeRule.runOnIdle { assert(style == JobisTypography.Caption) } | ||
} | ||
} |
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
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
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
Oops, something went wrong.