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
useLowercase = false, .MainType
), .Passcode
.PasscodeType
.Password
.ToggleLowercaseLettersChange(
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
useSpecialChars = true, .MainType
), .Passcode
.PasscodeType
.Password
.ToggleSpecialCharactersChange(
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,9 +481,14 @@ class GeneratorScreenTest : BaseComposeTest() {
verify { verify {
viewModel.trySendAction( viewModel.trySendAction(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleAvoidAmbigousCharactersChange( GeneratorAction
avoidAmbiguousChars = true, .MainType
), .Passcode
.PasscodeType
.Password
.ToggleAvoidAmbigousCharactersChange(
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,9 +144,14 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val useCapitals = true val useCapitals = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleCapitalLettersChange( GeneratorAction
useCapitals = useCapitals, .MainType
), .Passcode
.PasscodeType
.Password
.ToggleCapitalLettersChange(
useCapitals = useCapitals,
),
) )
val expectedState = defaultPasswordState.copy( val expectedState = defaultPasswordState.copy(
@ -170,9 +173,14 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val useLowercase = true val useLowercase = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleLowercaseLettersChange( GeneratorAction
useLowercase = useLowercase, .MainType
), .Passcode
.PasscodeType
.Password
.ToggleLowercaseLettersChange(
useLowercase = useLowercase,
),
) )
val expectedState = defaultPasswordState.copy( val expectedState = defaultPasswordState.copy(
@ -218,9 +226,14 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val useSpecialChars = true val useSpecialChars = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleSpecialCharactersChange( GeneratorAction
useSpecialChars = useSpecialChars, .MainType
), .Passcode
.PasscodeType
.Password
.ToggleSpecialCharactersChange(
useSpecialChars = useSpecialChars,
),
) )
val expectedState = defaultPasswordState.copy( val expectedState = defaultPasswordState.copy(
@ -266,9 +279,14 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val minSpecial = 2 val minSpecial = 2
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.MinSpecialCharactersChange( GeneratorAction
minSpecial = minSpecial, .MainType
), .Passcode
.PasscodeType
.Password
.MinSpecialCharactersChange(
minSpecial = minSpecial,
),
) )
val expectedState = defaultPasswordState.copy( val expectedState = defaultPasswordState.copy(
@ -291,9 +309,14 @@ class GeneratorViewModelTest : BaseViewModelTest() {
val avoidAmbiguousChars = true val avoidAmbiguousChars = true
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Password.ToggleAvoidAmbigousCharactersChange( GeneratorAction
avoidAmbiguousChars = avoidAmbiguousChars, .MainType
), .Passcode
.PasscodeType
.Password
.ToggleAvoidAmbigousCharactersChange(
avoidAmbiguousChars = avoidAmbiguousChars,
),
) )
val expectedState = defaultPasswordState.copy( val expectedState = defaultPasswordState.copy(
@ -330,9 +353,14 @@ 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
numWords = newNumWords, .MainType
), .Passcode
.PasscodeType
.Passphrase
.NumWordsCounterChange(
numWords = newNumWords,
),
) )
val expectedState = defaultPassphraseState.copy( val expectedState = defaultPassphraseState.copy(
@ -382,9 +410,14 @@ class GeneratorViewModelTest : BaseViewModelTest() {
runTest { runTest {
viewModel.eventFlow.test { viewModel.eventFlow.test {
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.ToggleIncludeNumberChange( GeneratorAction
includeNumber = true, .MainType
), .Passcode
.PasscodeType
.Passphrase
.ToggleIncludeNumberChange(
includeNumber = true,
),
) )
val expectedState = defaultPassphraseState.copy( val expectedState = defaultPassphraseState.copy(
@ -405,9 +438,14 @@ class GeneratorViewModelTest : BaseViewModelTest() {
runTest { runTest {
viewModel.eventFlow.test { viewModel.eventFlow.test {
viewModel.actionChannel.trySend( viewModel.actionChannel.trySend(
GeneratorAction.MainType.Passcode.PasscodeType.Passphrase.ToggleCapitalizeChange( GeneratorAction
capitalize = true, .MainType
), .Passcode
.PasscodeType
.Passphrase
.ToggleCapitalizeChange(
capitalize = true,
),
) )
val expectedState = defaultPassphraseState.copy( val expectedState = defaultPassphraseState.copy(
@ -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,