Updating generator tests formatting (#128)

This commit is contained in:
joshua-livefront 2023-10-18 10:53:14 -04:00 committed by Álison Fernandes
parent 0c50babd23
commit d6fe960bab
2 changed files with 196 additions and 49 deletions

View file

@ -1,5 +1,3 @@
@file:Suppress("MaxLineLength")
package com.x8bit.bitwarden.ui.tools.feature.generator package com.x8bit.bitwarden.ui.tools.feature.generator
import androidx.compose.ui.semantics.ProgressBarRangeInfo import androidx.compose.ui.semantics.ProgressBarRangeInfo
@ -33,7 +31,15 @@ class GeneratorScreenTest : BaseComposeTest() {
private val mutableStateFlow = MutableStateFlow( private val mutableStateFlow = MutableStateFlow(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Password()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Password(),
),
), ),
) )
@ -91,7 +97,9 @@ class GeneratorScreenTest : BaseComposeTest() {
.performClick() .performClick()
verify { verify {
viewModel.trySendAction(GeneratorAction.MainTypeOptionSelect(GeneratorState.MainTypeOption.PASSWORD)) viewModel.trySendAction(
GeneratorAction.MainTypeOptionSelect(GeneratorState.MainTypeOption.PASSWORD),
)
} }
} }
@ -185,6 +193,7 @@ class GeneratorScreenTest : BaseComposeTest() {
.assertIsDisplayed() .assertIsDisplayed()
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, adjusting the slider should send SliderLengthChange action with length not equal to default`() { fun `in Passcode_Password state, adjusting the slider should send SliderLengthChange action with length not equal to default`() {
composeTestRule.setContent { composeTestRule.setContent {
@ -217,6 +226,7 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, toggling the capital letters toggle should send ToggleCapitalLettersChange action`() { fun `in Passcode_Password state, toggling the capital letters toggle should send ToggleCapitalLettersChange action`() {
composeTestRule.setContent { composeTestRule.setContent {
@ -236,6 +246,7 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, toggling the use lowercase toggle should send ToggleLowercaseLettersChange action`() { fun `in Passcode_Password state, toggling the use lowercase toggle should send ToggleLowercaseLettersChange action`() {
composeTestRule.setContent { composeTestRule.setContent {
@ -248,13 +259,19 @@ class GeneratorScreenTest : BaseComposeTest() {
verify { verify {
viewModel.trySendAction( viewModel.trySendAction(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleLowercaseLettersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.ToggleLowercaseLettersChange(
useLowercase = false, useLowercase = false,
), ),
) )
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, toggling the use numbers toggle should send ToggleNumbersChange action`() { fun `in Passcode_Password state, toggling the use numbers toggle should send ToggleNumbersChange action`() {
composeTestRule.setContent { composeTestRule.setContent {
@ -274,6 +291,7 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, toggling the use special characters toggle should send ToggleSpecialCharactersChange action`() { fun `in Passcode_Password state, toggling the use special characters toggle should send ToggleSpecialCharactersChange action`() {
composeTestRule.setContent { composeTestRule.setContent {
@ -286,20 +304,34 @@ class GeneratorScreenTest : BaseComposeTest() {
verify { verify {
viewModel.trySendAction( viewModel.trySendAction(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleSpecialCharactersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.ToggleSpecialCharactersChange(
useSpecialChars = true, useSpecialChars = true,
), ),
) )
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, decrementing the minimum numbers counter should send MinNumbersCounterChange action`() { fun `in Passcode_Password state, decrementing the minimum numbers counter should send MinNumbersCounterChange action`() {
val initialMinNumbers = 1 val initialMinNumbers = 1
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Password()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Password(),
),
), ),
) )
@ -322,13 +354,22 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, incrementing the minimum numbers counter should send MinNumbersCounterChange action`() { fun `in Passcode_Password state, incrementing the minimum numbers counter should send MinNumbersCounterChange action`() {
val initialMinNumbers = 1 val initialMinNumbers = 1
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Password()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Password(),
),
), ),
) )
@ -351,13 +392,22 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, decrementing the minimum special characters counter should send MinSpecialCharactersChange action`() { fun `in Passcode_Password state, decrementing the minimum special characters counter should send MinSpecialCharactersChange action`() {
val initialSpecialChars = 1 val initialSpecialChars = 1
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Password()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Password(),
),
), ),
) )
@ -380,13 +430,22 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, incrementing the minimum special characters counter should send MinSpecialCharactersChange action`() { fun `in Passcode_Password state, incrementing the minimum special characters counter should send MinSpecialCharactersChange action`() {
val initialSpecialChars = 1 val initialSpecialChars = 1
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Password()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Password(),
),
), ),
) )
@ -409,6 +468,7 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Password state, toggling the use avoid ambiguous characters toggle should send ToggleSpecialCharactersChange action`() { fun `in Passcode_Password state, toggling the use avoid ambiguous characters toggle should send ToggleSpecialCharactersChange action`() {
composeTestRule.setContent { composeTestRule.setContent {
@ -421,7 +481,12 @@ class GeneratorScreenTest : BaseComposeTest() {
verify { verify {
viewModel.trySendAction( viewModel.trySendAction(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleAvoidAmbigousCharactersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.ToggleAvoidAmbigousCharactersChange(
avoidAmbiguousChars = true, avoidAmbiguousChars = true,
), ),
) )
@ -432,13 +497,22 @@ class GeneratorScreenTest : BaseComposeTest() {
//region Passcode Passphrase Tests //region Passcode Passphrase Tests
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Passphrase state, decrementing number of words should send NumWordsCounterChange action with decremented value`() { fun `in Passcode_Passphrase state, decrementing number of words should send NumWordsCounterChange action with decremented value`() {
val initialNumWords = 3 val initialNumWords = 3
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Passphrase()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Passphrase(),
),
), ),
) )
@ -463,13 +537,22 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Passphrase state, incrementing number of words should send NumWordsCounterChange action with incremented value`() { fun `in Passcode_Passphrase state, incrementing number of words should send NumWordsCounterChange action with incremented value`() {
val initialNumWords = 3 val initialNumWords = 3
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Passphrase()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Passphrase(),
),
), ),
) )
@ -493,12 +576,21 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Passphrase state, toggling capitalize should send ToggleCapitalizeChange action`() { fun `in Passcode_Passphrase state, toggling capitalize should send ToggleCapitalizeChange action`() {
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Passphrase()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Passphrase(),
),
), ),
) )
@ -520,12 +612,21 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Passphrase state, toggling the include number toggle should send ToggleIncludeNumberChange action`() { fun `in Passcode_Passphrase state, toggling the include number toggle should send ToggleIncludeNumberChange action`() {
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Passphrase()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Passphrase(),
),
), ),
) )
@ -546,12 +647,21 @@ class GeneratorScreenTest : BaseComposeTest() {
} }
} }
@Suppress("MaxLineLength")
@Test @Test
fun `in Passcode_Passphrase state, updating text in word separator should send WordSeparatorTextChange action`() { fun `in Passcode_Passphrase state, updating text in word separator should send WordSeparatorTextChange action`() {
updateState( updateState(
GeneratorState( GeneratorState(
generatedText = "Placeholder", generatedText = "Placeholder",
selectedType = GeneratorState.MainType.Passcode(GeneratorState.MainType.Passcode.PasscodeType.Passphrase()), selectedType = GeneratorState
.MainType
.Passcode(
GeneratorState
.MainType
.Passcode
.PasscodeType
.Passphrase(),
),
), ),
) )

View file

@ -1,5 +1,3 @@
@file:Suppress("MaxLineLength")
package com.x8bit.bitwarden.ui.tools.feature.generator package com.x8bit.bitwarden.ui.tools.feature.generator
import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.SavedStateHandle
@ -146,7 +144,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val useCapitals = true val useCapitals = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleCapitalLettersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.ToggleCapitalLettersChange(
useCapitals = useCapitals, useCapitals = useCapitals,
), ),
) )
@ -170,7 +173,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val useLowercase = true val useLowercase = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleLowercaseLettersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.ToggleLowercaseLettersChange(
useLowercase = useLowercase, useLowercase = useLowercase,
), ),
) )
@ -218,7 +226,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val useSpecialChars = true val useSpecialChars = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleSpecialCharactersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.ToggleSpecialCharactersChange(
useSpecialChars = useSpecialChars, useSpecialChars = useSpecialChars,
), ),
) )
@ -266,7 +279,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val minSpecial = 2 val minSpecial = 2
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.MinSpecialCharactersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.MinSpecialCharactersChange(
minSpecial = minSpecial, minSpecial = minSpecial,
), ),
) )
@ -291,7 +309,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val avoidAmbiguousChars = true val avoidAmbiguousChars = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleAvoidAmbigousCharactersChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Password
.ToggleAvoidAmbigousCharactersChange(
avoidAmbiguousChars = avoidAmbiguousChars, avoidAmbiguousChars = avoidAmbiguousChars,
), ),
) )
@ -330,7 +353,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
viewModel.eventFlow.test { viewModel.eventFlow.test {
val newNumWords = 4 val newNumWords = 4
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.NumWordsCounterChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Passphrase
.NumWordsCounterChange(
numWords = newNumWords, numWords = newNumWords,
), ),
) )
@ -382,7 +410,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
runTest { runTest {
viewModel.eventFlow.test { viewModel.eventFlow.test {
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.ToggleIncludeNumberChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Passphrase
.ToggleIncludeNumberChange(
includeNumber = true, includeNumber = true,
), ),
) )
@ -405,7 +438,12 @@ class GeneratorViewModelTest : BaseViewModelTest() {
runTest { runTest {
viewModel.eventFlow.test { viewModel.eventFlow.test {
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.ToggleCapitalizeChange( GeneratorAction
.MainType
.Passcode
.PasscodeType
.Passphrase
.ToggleCapitalizeChange(
capitalize = true, capitalize = true,
), ),
) )
@ -426,7 +464,6 @@ class GeneratorViewModelTest : BaseViewModelTest() {
//region Helper Functions //region Helper Functions
@Suppress("LongParameterList") @Suppress("LongParameterList")
private fun createPasswordState( private fun createPasswordState(
generatedText: String = "Placeholder", generatedText: String = "Placeholder",
length: Int = 14, length: Int = 14,