-
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
1 parent
0d1abae
commit ed2ed1d
Showing
113 changed files
with
5,930 additions
and
7 deletions.
There are no files selected for viewing
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1,409 changes: 1,409 additions & 0 deletions
1,409
card-payments/src/test/java/com/paysafe/android/hostedfields/PSCardFormControllerTest.kt
Large diffs are not rendered by default.
Oops, something went wrong.
40 changes: 40 additions & 0 deletions
40
card-payments/src/test/java/com/paysafe/android/hostedfields/PSThemeTest.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,40 @@ | ||
/* | ||
* Copyright (c) 2024 Paysafe Group | ||
*/ | ||
|
||
package com.paysafe.android.hostedfields | ||
|
||
import org.junit.Assert.assertNotNull | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
import org.robolectric.RuntimeEnvironment | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class PSThemeTest { | ||
|
||
@Test | ||
fun `IF context is provided THEN provideDefaultPSTheme RETURNS not null data`() { | ||
// Arrange | ||
val input = RuntimeEnvironment.getApplication().baseContext | ||
|
||
// Act | ||
val output = provideDefaultPSTheme(input) | ||
|
||
// Assert | ||
assertNotNull(output.backgroundColor) | ||
assertNotNull(output.borderColor) | ||
assertNotNull(output.focusedBorderColor) | ||
assertNotNull(output.borderCornerRadius) | ||
assertNotNull(output.errorColor) | ||
assertNotNull(output.textInputColor) | ||
assertNotNull(output.textInputFontSize) | ||
assertNotNull(output.placeholderColor) | ||
assertNotNull(output.placeholderFontSize) | ||
assertNotNull(output.hintColor) | ||
assertNotNull(output.hintFontSize) | ||
assertNotNull(output.expiryPickerButtonBackgroundColor) | ||
assertNotNull(output.expiryPickerButtonTextColor) | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
...ayments/src/test/java/com/paysafe/android/hostedfields/cardnumber/CardNumberSpacesTest.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,40 @@ | ||
/* | ||
* Copyright (c) 2024 Paysafe Group | ||
*/ | ||
|
||
package com.paysafe.android.hostedfields.cardnumber | ||
|
||
import com.paysafe.android.hostedfields.valid.CardNumberChecks.Companion.MAX_CHARS_FOR_AMEX_CARD | ||
import com.paysafe.android.hostedfields.valid.CardNumberChecks.Companion.MAX_CHARS_FOR_CARD_NUMBERS | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
|
||
class CardNumberSpacesTest { | ||
|
||
private val sut = CardNumberSpaces | ||
|
||
@Test | ||
fun `IF cursor passes the max THEN amex transformedToOriginal RETURNS max chars for amex`() { | ||
// Arrange | ||
val input = 18 | ||
|
||
// Act | ||
val output = sut.amexSpacesMapping.transformedToOriginal(input) | ||
|
||
// Assert | ||
assertEquals(MAX_CHARS_FOR_AMEX_CARD, output) | ||
} | ||
|
||
@Test | ||
fun `IF cursor passes the max THEN transformedToOriginal RETURNS default max chars`() { | ||
// Arrange | ||
val input = 20 | ||
|
||
// Act | ||
val output = sut.defaultSpacesMapping.transformedToOriginal(input) | ||
|
||
// Assert | ||
assertEquals(MAX_CHARS_FOR_CARD_NUMBERS, output) | ||
} | ||
|
||
} |
99 changes: 99 additions & 0 deletions
99
...yments/src/test/java/com/paysafe/android/hostedfields/cardnumber/PSCardNumberFieldTest.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,99 @@ | ||
/* | ||
* Copyright (c) 2024 Paysafe Group | ||
*/ | ||
|
||
package com.paysafe.android.hostedfields.cardnumber | ||
|
||
import androidx.compose.ui.Modifier | ||
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.lifecycle.MutableLiveData | ||
import com.paysafe.android.hostedfields.domain.model.CardNumberSeparator | ||
import com.paysafe.android.hostedfields.domain.model.PSCardNumberState | ||
import com.paysafe.android.hostedfields.domain.model.PSCardNumberStateImpl | ||
|
||
import com.paysafe.android.hostedfields.model.DefaultPSCardFieldEventHandler | ||
import com.paysafe.android.hostedfields.model.PSCardFieldEventHandler | ||
|
||
import com.paysafe.android.hostedfields.provideDefaultPSTheme | ||
import com.paysafe.android.hostedfields.util.PS_CARD_NUMBER_NO_ANIM_LABEL_TEST_TAG | ||
import com.paysafe.android.paymentmethods.domain.model.PSCreditCardType | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class PSCardNumberFieldTest { | ||
|
||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
private fun cardNumberNoAnimationLabel() = composeTestRule.onNodeWithTag( | ||
PS_CARD_NUMBER_NO_ANIM_LABEL_TEST_TAG | ||
) | ||
|
||
private fun sut( | ||
state: PSCardNumberState = PSCardNumberStateImpl(), | ||
animateTopLabelText: Boolean, | ||
numbersSeparator: CardNumberSeparator = CardNumberSeparator.DASH, | ||
eventHandler: PSCardFieldEventHandler = DefaultPSCardFieldEventHandler(MutableLiveData(false)) | ||
) { | ||
composeTestRule.setContent { | ||
PSCardNumberField( | ||
cardNumberState = state, | ||
cardNumberModifier = PSCardNumberModifier( | ||
modifier = Modifier, | ||
cardBrandModifier = Modifier | ||
), | ||
labelText = "Card Number", | ||
placeholderText = "XXXX XXXX XXXX XXXX", | ||
animateTopLabelText = animateTopLabelText, | ||
cardNumberLiveData = PSCardNumberLiveData( | ||
cardTypeLiveData = MutableLiveData(PSCreditCardType.UNKNOWN), | ||
isValidLiveData = MutableLiveData(false) | ||
), | ||
psTheme = provideDefaultPSTheme(), | ||
separator = numbersSeparator, | ||
eventHandler = eventHandler | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun `IF PSCardNumberField not animating top label PERFORMING just click TRIGGER label without animation display`() { | ||
// Arrange | ||
val animateTop = false | ||
val cardNumberStateInput = PSCardNumberStateImpl() | ||
cardNumberStateInput.value = "" | ||
cardNumberStateInput.isFocused = false | ||
cardNumberStateInput.isValidInUi = true | ||
sut(state = cardNumberStateInput, animateTopLabelText = animateTop) | ||
|
||
// Act | ||
cardNumberNoAnimationLabel().performClick() | ||
|
||
// Assert | ||
cardNumberNoAnimationLabel().assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun `IF PSCardNumberField not animating top label, and not valid in ui PERFORMING just click TRIGGER label without animation display`() { | ||
// Arrange | ||
val animateTop = false | ||
val cardNumberStateInput = PSCardNumberStateImpl() | ||
cardNumberStateInput.value = "" | ||
cardNumberStateInput.isFocused = false | ||
cardNumberStateInput.isValidInUi = false | ||
sut(state = cardNumberStateInput, animateTopLabelText = animateTop) | ||
|
||
// Act | ||
cardNumberNoAnimationLabel().performClick() | ||
|
||
// Assert | ||
cardNumberNoAnimationLabel().assertIsDisplayed() | ||
} | ||
|
||
} |
Oops, something went wrong.