Skip to content

Commit

Permalink
0.0.42
Browse files Browse the repository at this point in the history
  • Loading branch information
PaysafeAutoCommitter committed Aug 29, 2024
1 parent 0d1abae commit ed2ed1d
Show file tree
Hide file tree
Showing 113 changed files with 5,930 additions and 7 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ android {
ignoreTestSources = LintConfig.ignoreTestSources
explainIssues = LintConfig.explainIssues
noLines = LintConfig.noLines
textOutput = LintConfig.getTextOutputFileName("hosted-fields")
htmlOutput = LintConfig.getHtmlOutputFile("hosted-fields")
textOutput = LintConfig.getTextOutputFileName("card-payments")
htmlOutput = LintConfig.getHtmlOutputFile("card-payments")
disable += LintConfig.disableRules
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

Large diffs are not rendered by default.

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)
}

}
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)
}

}
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()
}

}
Loading

0 comments on commit ed2ed1d

Please sign in to comment.