Skip to content

Commit

Permalink
F253333: SAQ-A Native Components (#105)
Browse files Browse the repository at this point in the history
* Us1762585 - iOS Refactor Native components (#81)

* US1762570: create view manager to native AccessCheckoutEditText component; override onTextChange to support the react native onChangeText event; implement component in react native

* US1762550: update card details field to use new component; update RN module to use reference to AccessCheckoutEditText and not the text value

* US1762550: move AccessCheckoutEditTextManager to correct file path; update local android sdk files to most up-to-date version of master; update AccessCheckoutReactPackageTest

* US1782181: add unit tests for AccessCheckoutEditTextManagerTest; add mockito to build.gradle for unit tests

* US1762551: Expose AccessCheckoutUITextField to be able to use native components via the ios Bridge
Simplify ReactNativeViewLocator and implement/expose specific POC methods to avoid disruptions with previous implementation
Add POC toggle to demo app to be able to switch implementations
Expose new POC validation and sessionGeneration methods to avoid diruptions with previous implementations

* US1762551: Point client to npe environment

* US1762585: Refactor ios Bridge and demo application
Avoids having to handle inputs in states
Uses native components
Only a input field id is needed in order to configure validation and session generation for a field
Integrate the latest AccessCheckoutUITextField changes
Updates and renames cvcValue to cvcId
Updates and renames panValue to panId
Updates and renames expiryDateValue to expiryDateId

* US1762585: Rebuild lib and clean up files

* US1762585: Minor cleanup

* US1762585: Rebuild lib files
Rename AccessCheckoutEditText to AccessCheckoutInputText as EditText was specific to Android
Minor renaming of fields like panUITextField to panACUITextField to improve readability and make it known that we are dealing with AccessCheckoutUITextField in the iOS bridge

* US1762585:
Rename AccessCheckoutEditText to AccessCheckoutInputText in Android bridge

* US1762585:
Rename AccessCheckoutInputText to AccessCheckoutTextInput
Rebuild lib files

* US1762585: Update bitrise-step to use xcode-test v5 and update e2e tests (#82)

* US1762585: Update bitrise-step to use xcode-test v5

* US1762585: Use Optionals to mantain compatibility in both Xcode 13 and Xcode 15

* US1762585: Update e2e tests

* US1762585: Improve matcher based on platform using type

* US1762585: Remove TextInputPO as it is no longer used

---------

Co-authored-by: e5661323 <jason.dzelamensah@fisglobal.com>

* US1782181: change Android bridge GenerateSessionsConfig to use panId, expiryDateId, cvcId instead of panValue, expiryDateValue, cvcValue. Change all instrumented tests to use AccessCheckoutEditText and refactor them for easier maintenance

* US1782181: update Android emulator boot timeout to cater for longer boot times

* US1782181: patch Boost pod.spec while issue is being fixed
- See Boost issue - boostorg/boost#843
- See temporary workaround proposed by Facebook - facebook/react-native#42180

* US1762588 - [iOS] React Native Demo Components Refactor and Props (#86)

* Us1762585 - iOS Refactor Native components (#81)

* US1762570: create view manager to native AccessCheckoutEditText component; override onTextChange to support the react native onChangeText event; implement component in react native

* US1762550: update card details field to use new component; update RN module to use reference to AccessCheckoutEditText and not the text value

* US1762550: move AccessCheckoutEditTextManager to correct file path; update local android sdk files to most up-to-date version of master; update AccessCheckoutReactPackageTest

* US1782181: add unit tests for AccessCheckoutEditTextManagerTest; add mockito to build.gradle for unit tests

* US1762551: Expose AccessCheckoutUITextField to be able to use native components via the ios Bridge
Simplify ReactNativeViewLocator and implement/expose specific POC methods to avoid disruptions with previous implementation
Add POC toggle to demo app to be able to switch implementations
Expose new POC validation and sessionGeneration methods to avoid diruptions with previous implementations

* US1762551: Point client to npe environment

* US1762585: Refactor ios Bridge and demo application
Avoids having to handle inputs in states
Uses native components
Only a input field id is needed in order to configure validation and session generation for a field
Integrate the latest AccessCheckoutUITextField changes
Updates and renames cvcValue to cvcId
Updates and renames panValue to panId
Updates and renames expiryDateValue to expiryDateId

* US1762585: Rebuild lib and clean up files

* US1762585: Minor cleanup

* US1762585: Rebuild lib files
Rename AccessCheckoutEditText to AccessCheckoutInputText as EditText was specific to Android
Minor renaming of fields like panUITextField to panACUITextField to improve readability and make it known that we are dealing with AccessCheckoutUITextField in the iOS bridge

* US1762585:
Rename AccessCheckoutEditText to AccessCheckoutInputText in Android bridge

* US1762585:
Rename AccessCheckoutInputText to AccessCheckoutTextInput
Rebuild lib files

* US1762585: Update bitrise-step to use xcode-test v5 and update e2e tests (#82)

* US1762585: Update bitrise-step to use xcode-test v5

* US1762585: Use Optionals to mantain compatibility in both Xcode 13 and Xcode 15

* US1762585: Update e2e tests

* US1762585: Improve matcher based on platform using type

* US1762585: Remove TextInputPO as it is no longer used

---------

Co-authored-by: e5661323 <jason.dzelamensah@fisglobal.com>

* US1762588: Clean and Refactor CVC Expiry and Pan React Native Demo components
Define Props and types to ReactNative component and Native component props

* US1762588: Use paddingHorizontal in demo components

* US1762588: Add Android AccessCheckoutEditText defaults when initialising the component

* US1762588: Add Support for fonts via styling, minor refactorings

* US1762588: Remove Comment and support for keyboartType in iOS Bridge

* US1762588: Revert pod local version

* US1762588: rebuild pod files to point to remote AccessCheckoutSDK

* US1762588: rebuild pod files to point to remote AccessCheckoutSDK

* US1762588: Remove support for fontStyle and fontWeight

* US1762588: Add correct colours to text when input is not editable, remove inverted expression

* US1762588: Fixx import after rebase

* US1762588: Clean imports

* US1762588: Remove unnecessary comments

* US1762588: Rename fontColor to color, and remap in iOS Bridge
Reset defaults provided by AccessCheckoutUITextfield
Reset insets using horizontalPadding in AccessCheckoutUITextfield

* US1762588: point to correct tag instad of branch

* US1762588: Update pod deps

* US1762588: change BitRise flow for iOS Bridge and iOS e2e tests to update and install Pods rather than just install

---------

Co-authored-by: e5661323 <jason.dzelamensah@fisglobal.com>
Co-authored-by: Olivier Chalet <olivier.chalet@fisglobal.com>

* US1762599 - [Android] React Native Demo Components Refactor and Props (#87)

* US1762588: Add Support for fonts via styling, minor refactorings

* US1762588: Revert pod local version

* US1762588: rebuild pod files to point to remote AccessCheckoutSDK

* US1782181: change app to display error in a div rather as an alert

* US1762599: add support for fontSize, placeholderColor & borderColor

* US1762599: update textColor support; add support for font; update unit tests

* US1762599: run format task

* US1762599: update access-checkout-android 3.0.0 to latest jar

* US1762599: add customType to AccessCheckoutTextInputManager to allow color to be parsed correctly from demo-app

Co-authored-by: abaeza-wp <153538325+abaeza-wp@users.noreply.github.com>
Co-authored-by: Olivier Chalet <olivier.chalet@fisglobal.com>

* Us1762585 - iOS Refactor Native components (#81)

* US1762570: create view manager to native AccessCheckoutEditText component; override onTextChange to support the react native onChangeText event; implement component in react native

* US1762550: update card details field to use new component; update RN module to use reference to AccessCheckoutEditText and not the text value

* US1762550: move AccessCheckoutEditTextManager to correct file path; update local android sdk files to most up-to-date version of master; update AccessCheckoutReactPackageTest

* US1782181: add unit tests for AccessCheckoutEditTextManagerTest; add mockito to build.gradle for unit tests

* US1762551: Expose AccessCheckoutUITextField to be able to use native components via the ios Bridge
Simplify ReactNativeViewLocator and implement/expose specific POC methods to avoid disruptions with previous implementation
Add POC toggle to demo app to be able to switch implementations
Expose new POC validation and sessionGeneration methods to avoid diruptions with previous implementations

* US1762551: Point client to npe environment

* US1762585: Refactor ios Bridge and demo application
Avoids having to handle inputs in states
Uses native components
Only a input field id is needed in order to configure validation and session generation for a field
Integrate the latest AccessCheckoutUITextField changes
Updates and renames cvcValue to cvcId
Updates and renames panValue to panId
Updates and renames expiryDateValue to expiryDateId

* US1762585: Rebuild lib and clean up files

* US1762585: Minor cleanup

* US1762585: Rebuild lib files
Rename AccessCheckoutEditText to AccessCheckoutInputText as EditText was specific to Android
Minor renaming of fields like panUITextField to panACUITextField to improve readability and make it known that we are dealing with AccessCheckoutUITextField in the iOS bridge

* US1762585:
Rename AccessCheckoutEditText to AccessCheckoutInputText in Android bridge

* US1762585:
Rename AccessCheckoutInputText to AccessCheckoutTextInput
Rebuild lib files

* US1762585: Update bitrise-step to use xcode-test v5 and update e2e tests (#82)

* US1762585: Update bitrise-step to use xcode-test v5

* US1762585: Use Optionals to mantain compatibility in both Xcode 13 and Xcode 15

* US1762585: Update e2e tests

* US1762585: Improve matcher based on platform using type

* US1762585: Remove TextInputPO as it is no longer used

---------

Co-authored-by: e5661323 <jason.dzelamensah@fisglobal.com>

* US1782181: change app to display error in a div rather as an alert

* US1762599: add support for fontSize, placeholderColor & borderColor

* US1762599: update textColor support; add support for font; update unit tests

* US1762599: run format task

* US1762588: Use paddingHorizontal in demo components

* US1762588: rebuild pod files to point to remote AccessCheckoutSDK

* US1762588: Clean imports

* US1764971: Create useAccessCheckout Custom hook
Refactor application and model to take in CardConfiguration and CvcOnlyCardConfiguration
Refactor application to make useCardValidation and useCvcOnlyValidation internal hooks
Rebuild libraries with bob
Update tests and add @testing-library/react-native renderHook

* US1764971: Clean up

* US1764971: Re-build lib files

* US1764971: Re-build dependency files to fix an error caused when installing dependencies

* US1764971: expose useCvcOnlyConfig and useCardConfig to provide better experience when initialising configuration for useAccessCheckout
Added ValidationListenerException to ensure an error is raised when attempting to use initialiseValidation when no validationConfig is provided, This provides the developers with a clear readable error message and enhances their debugging experience.

* US1764971: Fix prettier

* US1764971: rebuild lib files

* US1764971: Differentiate between props interface and config classes as it was creating confusion by renaming CardConfig and CvconlyConfig classes and validation classes to be prefixed with Merchant

* US1764971: Differentiate between props interface and config classes as it was creating confusion by renaming CardConfig and CvconlyConfig classes and validation classes to be prefixed with Merchant

* Us1833001: [Android]  Add font support (#96)

* US1833001: Add Android support for font customization including font weight and font style

* US1833001: Add Android support for font customization including font weight and font style and checks for support of font weight in android api >28

* US1833001: Better comment to explain why the use of font.getInt() was not used

* US1764780 - Within the README under the access-checkout-react-native-sdk folder, write a section on SAQ-A compliance and a section on AccessCheckoutTextInput which has a link to the documentation (#99)

* F253333: Export AccessCheckoutTextInput and props (#104)

* F253333: Export AccessCheckoutTextInput and props

* F253333: Add mock for requireNativeComponent

---------

Co-authored-by: e5661323 <jason.dzelamensah@fisglobal.com>
Co-authored-by: Olivier Chalet <olivier.chalet@fisglobal.com>
Co-authored-by: Jason <101661402+jmensahWP@users.noreply.github.com>
Co-authored-by: ochalet-wp <59016148+ochalet-wp@users.noreply.github.com>
  • Loading branch information
5 people committed Feb 8, 2024
1 parent ba5b406 commit 1b83b45
Show file tree
Hide file tree
Showing 208 changed files with 11,171 additions and 4,917 deletions.
3 changes: 1 addition & 2 deletions access-checkout-react-native-sdk/.prettierrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"tabWidth": 2,
"trailingComma": "es5",
"useTabs": false,
"arrowParens": "avoid",
"bracketSameLine": true
"printWidth": 120
}
13 changes: 11 additions & 2 deletions access-checkout-react-native-sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,27 @@ Create your own uniquely styled and branded checkout form by integrating our Rea
This SDK is the first step to integrate with our Access Worldpay APIs into a React Native app.
It is designed to simplify the integration of the following functionality in your checkout form:
- validating the format of the card details entered by a customer
- generating a session (short-lived token representing a customer's card details)
- generating a session (short-lived token representing a customer's card details)

## Documentation

You can find the detailed documentation explaining how to integrate the SDK and use a session to take a payment starting with the [React Native section](https://developer.worldpay.com/docs/access-worldpay/checkout/react-native) of the [Access Worldpay documentation](https://developer.worldpay.com).
You can find the detailed documentation explaining how to integrate the SDK and use a session to take a payment starting with the [React Native section](https://developer.worldpay.com/docs/access-worldpay/checkout/react-native) of the [Access Worldpay Checkout documentation](https://developer.worldpay.com).

## Compatibility

- `React Native 0.70.0` and above
- `React 18.1.0` and above
- `Cocoapods` only for iOS dependencies

## SAQ-A Compliance

To support SAQ-A compliance when using our React Native SDK, we have created a new component called AccessCheckoutTextInput:
It has been designed so that it does not expose any methods or properties to retrieve the text entered by the end user to ensure our merchants applications do not have direct access to card details and are SAQ-A compliant.

## AccessCheckoutTextInput

You can find detailed documentation about our new component [AccessCheckoutTextInput](https://developer.worldpay.com/docs/access-worldpay/checkout/react-native/optional-configuration) within the [React Native section](https://developer.worldpay.com/docs/access-worldpay/checkout/react-native) of the [Access Worldpay Checkout documentation](https://developer.worldpay.com).

## How to install

Refer to [Get our SDK](https://developer.worldpay.com/docs/access-worldpay/checkout/react-native#get-our-sdk) in the React Native section of the [Access Worldpay documentation](https://developer.worldpay.com)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ dependencies {
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.assertj:assertj-core:3.21.0'
testImplementation 'org.robolectric:robolectric:4.4'
testImplementation 'org.mockito:mockito-core:5.8.0'


instrumentedTestsImplementation 'androidx.test:core:1.4.0'
instrumentedTestsImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@ package com.worldpay.access.checkout.reactnative.session
import android.content.Context
import androidx.test.core.app.ActivityScenario
import androidx.test.platform.app.InstrumentationRegistry
import com.github.tomakehurst.wiremock.client.WireMock.*
import com.github.tomakehurst.wiremock.client.WireMock.equalTo
import com.github.tomakehurst.wiremock.client.WireMock.postRequestedFor
import com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo
import com.github.tomakehurst.wiremock.client.WireMock.verify
import com.worldpay.access.checkout.reactnative.services.AccessServicesRootStub
import com.worldpay.access.checkout.reactnative.services.MockServer
import com.worldpay.access.checkout.reactnative.services.MockServer.startStubServices
import com.worldpay.access.checkout.reactnative.services.MockServer.stopStubServices
import com.worldpay.access.checkout.reactnative.services.SessionsStub
import com.worldpay.access.checkout.reactnative.session.SessionsTestFixture.Companion.CARD
import com.worldpay.access.checkout.reactnative.session.SessionsTestFixture.Companion.CVC
import com.worldpay.access.checkout.reactnative.session.SessionsTestFixture.Companion.sessionsTextFixture
import com.worldpay.access.checkout.reactnative.utils.TestFixture.Companion.CARD
import com.worldpay.access.checkout.reactnative.utils.TestFixture.Companion.CVC
import com.worldpay.access.checkout.reactnative.utils.TestFixture.Companion.testFixture
import org.awaitility.Awaitility.await
import org.junit.After
import org.junit.Before
Expand All @@ -20,11 +23,11 @@ import java.util.concurrent.TimeUnit.MILLISECONDS


class SessionsInstrumentedTests {
private val timeOutInMs = 5000L
private val timeOutInMs = 500000L

@Before
fun setup() {
sessionsTextFixture().clear()
testFixture().clear()

val context: Context = InstrumentationRegistry.getInstrumentation().context
startStubServices(context, MockServer.PORT)
Expand All @@ -41,11 +44,10 @@ class SessionsInstrumentedTests {
@Test
fun testShouldBeAbleToGenerateACardSession() {
SessionsStub.stubSessionsCardSuccess("my-session")
sessionsTextFixture().pan("4444333322221111")
testFixture().pan("4444333322221111")
.expiryDate("12/34")
.cvc("123")
.sessionsTypes(listOf(CARD))
.reactNativeSdkVersion("1.0.0")

val scenario = ActivityScenario.launch(SessionsInstrumentedTestsActivity::class.java)

Expand All @@ -58,11 +60,10 @@ class SessionsInstrumentedTests {
SessionsStub.stubSessionsCardSuccess("my-session")
SessionsStub.stubSessionsPaymentsCvcSuccess("my-other-session")

sessionsTextFixture().pan("4444333322221111")
testFixture().pan("4444333322221111")
.expiryDate("12/34")
.cvc("123")
.sessionsTypes(listOf(CARD, CVC))
.reactNativeSdkVersion("1.0.0")

val scenario = ActivityScenario.launch(SessionsInstrumentedTestsActivity::class.java)

Expand All @@ -77,10 +78,8 @@ class SessionsInstrumentedTests {
fun testShouldBeAbleToGenerateACvcOnlySession() {
SessionsStub.stubSessionsPaymentsCvcSuccess("my-other-session")

sessionsTextFixture()
.cvc("123")
testFixture().cvc("123")
.sessionsTypes(listOf(CVC))
.reactNativeSdkVersion("1.0.0")

val scenario = ActivityScenario.launch(SessionsInstrumentedTestsActivity::class.java)

Expand All @@ -99,38 +98,22 @@ class SessionsInstrumentedTests {
SessionsStub.stubSessionsCardSuccess("my-session")
SessionsStub.stubSessionsPaymentsCvcFailure(errorName, message)

sessionsTextFixture()
.pan("4444333322221111")
testFixture().pan("4444333322221111")
.expiryDate("12/34")
.cvc("123")
.sessionsTypes(listOf(CARD, CVC))
.reactNativeSdkVersion("1.0.0")

val scenario = ActivityScenario.launch(SessionsInstrumentedTestsActivity::class.java)

assertExceptionIs(scenario, expectedException)
}

@Test
fun testShouldBeAbleToGiveErrorWhenSessionsTypeContainsCvcAndANullCvcIsPassed() {
val exception = RuntimeException("Expected cvcValue to be provided but was not")

sessionsTextFixture()
.cvc(null)
.sessionsTypes(listOf(CVC))
.reactNativeSdkVersion("1.0.0")

val scenario = ActivityScenario.launch(SessionsInstrumentedTestsActivity::class.java)

assertExceptionIs(scenario, exception)
}

@Test
fun testShouldSetNativeSdkWpSdkHeaderWithAccessCheckoutReactNativeVersion() {
SessionsStub.stubSessionsCardSuccess("my-session")
SessionsStub.stubSessionsPaymentsCvcSuccess("my-other-session")

sessionsTextFixture().pan("4444333322221111")
testFixture().pan("4444333322221111")
.expiryDate("12/34")
.cvc("123")
.sessionsTypes(listOf(CARD, CVC))
Expand All @@ -147,7 +130,7 @@ class SessionsInstrumentedTests {
verify(
postRequestedFor(urlEqualTo("/sessions/payments/cvc"))
.withHeader("X-WP-SDK", equalTo("access-checkout-react-native/1.2.3"))
);
)
}

private fun assertSessionsAre(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,14 @@ import com.worldpay.access.checkout.reactnative.services.CardBrandsStub.Companio
import com.worldpay.access.checkout.reactnative.services.MockServer
import com.worldpay.access.checkout.reactnative.services.MockServer.startStubServices
import com.worldpay.access.checkout.reactnative.services.MockServer.stopStubServices
import com.worldpay.access.checkout.reactnative.validation.CardValidationTestFixture.Companion.validationTestFixture
import com.worldpay.access.checkout.reactnative.utils.TestFixture
import com.worldpay.access.checkout.reactnative.utils.TestFixture.Companion.testFixture
import org.awaitility.Awaitility.await
import org.junit.*
import org.junit.After
import org.junit.AfterClass
import org.junit.Before
import org.junit.BeforeClass
import org.junit.Test
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.TimeUnit.MILLISECONDS

Expand All @@ -38,13 +43,7 @@ class CardValidationInstrumentedTests {

@Before
fun setUp() {
validationTestFixture()
.clear()
.panId(CardValidationInstrumentedTestsActivity.panId)
.expiryDateId(CardValidationInstrumentedTestsActivity.expiryDateId)
.cvcId(CardValidationInstrumentedTestsActivity.cvcId)

CardValidationInstrumentedTestsActivity.clearActions()
TestFixture().clear()
}

@After
Expand All @@ -55,7 +54,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenPanBecomesValid() {
startActivity().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setPan("4444333322221111")
}

Expand All @@ -71,7 +70,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenPanBecomesInvalid() {
startActivity().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setPan("4444333322221111")
activity.setPan("4")
}
Expand All @@ -92,7 +91,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenExpiryDateBecomesValid() {
startActivity().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setExpiryDate("12/30")
}

Expand All @@ -108,7 +107,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenExpiryDateBecomesInvalid() {
startActivity().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setExpiryDate("12/30")
activity.setExpiryDate("12/3")
}
Expand All @@ -129,7 +128,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenCvcBecomesValid() {
startActivity().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setCvc("123")
}

Expand All @@ -145,7 +144,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenCvcBecomesInvalid() {
startActivity().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setCvc("123")
activity.setCvc("12")
}
Expand All @@ -166,7 +165,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenAllFieldsBecomeValid() {
startActivity().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setPan("4444333322221111")
activity.setExpiryDate("12/30")
activity.setCvc("123")
Expand All @@ -184,7 +183,7 @@ class CardValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenRecognisingCardBrand() {
startActivityWithCardBrandRules().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setPan("4")
}

Expand All @@ -211,10 +210,10 @@ class CardValidationInstrumentedTests {

@Test
fun shouldRaiseAnInvalidPanEventWhenCardBrandIsNotAcceptedByMerchant() {
validationTestFixture().acceptedCardBrands(listOf("jcb"))
testFixture().acceptedCardBrands(listOf("jcb"))

startActivityWithCardBrandRules().use { scenario ->
CardValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setPan("4")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import com.worldpay.access.checkout.reactnative.react.EventMock
import com.worldpay.access.checkout.reactnative.services.MockServer
import com.worldpay.access.checkout.reactnative.services.MockServer.startStubServices
import com.worldpay.access.checkout.reactnative.services.MockServer.stopStubServices
import com.worldpay.access.checkout.reactnative.validation.CvcOnlyValidationTestFixture.Companion.cvcOnlyValidationTestFixture
import org.awaitility.Awaitility.await
import org.junit.*
import org.junit.After
import org.junit.AfterClass
import org.junit.BeforeClass
import org.junit.Test
import java.util.concurrent.CopyOnWriteArrayList
import java.util.concurrent.TimeUnit.MILLISECONDS

Expand All @@ -34,15 +36,6 @@ class CvcOnlyValidationInstrumentedTests {
}


@Before
fun setUp() {
cvcOnlyValidationTestFixture()
.clear()
.cvcId(CvcOnlyValidationInstrumentedTestsActivity.cvcId)

CvcOnlyValidationInstrumentedTestsActivity.clearActions()
}

@After
fun tearDown() {
WireMock.reset()
Expand All @@ -51,7 +44,7 @@ class CvcOnlyValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenCvcBecomesValid() {
startActivity().use { scenario ->
CvcOnlyValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setCvc("123")
}

Expand All @@ -67,7 +60,7 @@ class CvcOnlyValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenCvcBecomesInvalid() {
startActivity().use { scenario ->
CvcOnlyValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setCvc("123")
activity.setCvc("12")
}
Expand All @@ -88,7 +81,7 @@ class CvcOnlyValidationInstrumentedTests {
@Test
fun shouldRaiseEventWhenAllFieldsBecomeValid() {
startActivity().use { scenario ->
CvcOnlyValidationInstrumentedTestsActivity.run { activity ->
scenario.onActivity { activity ->
activity.setCvc("123")
}

Expand Down

0 comments on commit 1b83b45

Please sign in to comment.