fidel-react-native 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +23 -114
- package/android/build.gradle +11 -11
- package/android/jacoco.gradle +50 -0
- package/android/src/main/java/com/fidelreactlibrary/FidelModule.java +12 -2
- package/android/src/main/java/com/fidelreactlibrary/adapters/FidelCountryAdapter.java +2 -0
- package/android/src/main/java/com/fidelreactlibrary/events/CallbackActivityEventListener.java +2 -6
- package/android/src/test/java/com/fidelreactlibrary/CallbackActivityEventListenerTests.java +31 -3
- package/android/src/test/java/com/fidelreactlibrary/FidelCardSchemesAdapterTests.java +5 -4
- package/android/src/test/java/com/fidelreactlibrary/FidelCountryAdapterTests.java +0 -1
- package/android/src/test/java/com/fidelreactlibrary/WritableMapDataConverterTests.java +8 -8
- package/android/src/test/resources/robolectric.properties +1 -0
- package/ios/FLRNOptionsAdapter.m +1 -1
- package/package.json +1 -1
- package/android/.project +0 -17
- package/android/.settings/org.eclipse.buildship.core.prefs +0 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Fidel React Native bridge library change log
|
|
2
2
|
|
|
3
|
+
## 1.5.0
|
|
4
|
+
- Remove card scanning confirmation screen.
|
|
5
|
+
|
|
6
|
+
## 1.4.3
|
|
7
|
+
- Add United Arab Emirates option as a country of issuance.
|
|
8
|
+
- Country label shrinks its font size, to fit longer country names, on smaller devices.
|
|
9
|
+
|
|
10
|
+
## 1.4.2
|
|
11
|
+
- Update Fidel Android SDK version to allow French & Swedish translations be available in more countries.
|
|
12
|
+
|
|
13
|
+
## 1.4.1
|
|
14
|
+
- Update Fidel & Android SDK versions.
|
|
15
|
+
- Prepare for the newest React Native versions.
|
|
16
|
+
- Fix some unit tests.
|
|
17
|
+
- Made it easier to automate testing this React Native bridge library.
|
|
18
|
+
|
|
3
19
|
## 1.4.0
|
|
4
20
|
|
|
5
21
|
- Now the SDK allows you to select multiple allowed countries from which the user can pick. Please check the docs for information about the new `allowedCountries` option.
|
package/README.md
CHANGED
|
@@ -7,21 +7,17 @@ This SDK is a bridge between React Native and Fidel's native iOS and Android SDK
|
|
|
7
7
|
|
|
8
8
|
## Getting started
|
|
9
9
|
|
|
10
|
-
`$ npm install fidel-react-native
|
|
10
|
+
`$ npm install fidel-react-native`
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
or
|
|
13
13
|
|
|
14
|
-
`$
|
|
14
|
+
`$ yarn add fidel-react-native`
|
|
15
15
|
|
|
16
16
|
### iOS
|
|
17
17
|
|
|
18
|
-
**1.**
|
|
18
|
+
**1.** Please make sure that the minimum platform is set to 9.1 in your Podfile: `platform :ios, '9.1'`.
|
|
19
19
|
|
|
20
|
-
`pod
|
|
21
|
-
|
|
22
|
-
**2.** Please make sure that the minimum platform is set to 9.1 in your Podfile: `platform :ios, '9.1'`.
|
|
23
|
-
|
|
24
|
-
**3.** Run `pod install`.
|
|
20
|
+
**2.** Run `pod install`.
|
|
25
21
|
|
|
26
22
|
### Android
|
|
27
23
|
|
|
@@ -48,109 +44,6 @@ buildscript {
|
|
|
48
44
|
}
|
|
49
45
|
```
|
|
50
46
|
|
|
51
|
-
## Manual linking
|
|
52
|
-
|
|
53
|
-
### iOS manual linking
|
|
54
|
-
|
|
55
|
-
#### Step 1: Add the Fidel React Native iOS project as a dependency
|
|
56
|
-
|
|
57
|
-
**1.** In XCode, in the project navigator, right click `Libraries` ➜ `Add Files to [your project's name]`
|
|
58
|
-
|
|
59
|
-
**2.** Go to `node_modules` ➜ `fidel-react-native` and add `Fidel.xcodeproj`
|
|
60
|
-
|
|
61
|
-
**3.** In XCode, in the project navigator, select your project. Add `libFidel.a` to your project's `Build Phases` ➜ `Link Binary With Libraries`
|
|
62
|
-
|
|
63
|
-
**4.** Under your target's `Build Settings`, make sure to set `YES` for `Always Embed Swift Standard Libraries`. That's because, by default, your project might not need it. It needs to be `YES` because otherwise the project will not find the Swift libraries to be able to run our native iOS SDK.
|
|
64
|
-
|
|
65
|
-
#### Step 2: Add the Native iOS SDK as a dependency
|
|
66
|
-
|
|
67
|
-
You can use Cocoapods or install the library as a dynamic library.
|
|
68
|
-
|
|
69
|
-
**5.** Add a `Podfile` in your `ios/` folder of your React Native project. It should include the following dependency:
|
|
70
|
-
|
|
71
|
-
```ruby
|
|
72
|
-
use_frameworks!
|
|
73
|
-
pod 'Fidel'
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
Here is the simplest `Podfile` you need to link with our native iOS SDK:
|
|
77
|
-
|
|
78
|
-
```ruby
|
|
79
|
-
platform :ios, '9.1'
|
|
80
|
-
|
|
81
|
-
workspace 'example'
|
|
82
|
-
|
|
83
|
-
target 'example' do
|
|
84
|
-
use_frameworks!
|
|
85
|
-
pod 'Fidel'
|
|
86
|
-
end
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
**6.** If you use an older Swift version, you should install a different `Fidel` pod version. If your project uses Swift `4.2.1`, for example, your Podfile should include `pod Fidel, '~>1.4'`, *not* `pod 'Fidel'` (which installs the latest version of the latest Swift supported version). Please check our [iOS SDK README (step 1)](https://github.com/FidelLimited/fidel-ios#step-1). You'll find a suitable version you should set for our Fidel iOS SDK.
|
|
90
|
-
|
|
91
|
-
**7.** Run `pod install` in your terminal.
|
|
92
|
-
|
|
93
|
-
**8.** Make sure to use the new `.xcworkspace` created by Cocoapods when you run your iOS app. React Native should use it by default.
|
|
94
|
-
|
|
95
|
-
**9.** In order to allow scanning cards with the camera, make sure to add the key `NSCameraUsageDescription` to your iOS app `Info.plist` and set the value to a string describing why your app needs to use the camera (e.g. "To scan credit cards."). This string will be displayed when the app initially requests permission to access the camera.
|
|
96
|
-
|
|
97
|
-
### Android manual linking
|
|
98
|
-
|
|
99
|
-
**1.** Append the following lines to `android/settings.gradle`:
|
|
100
|
-
|
|
101
|
-
```java
|
|
102
|
-
include ':fidel-react-native'
|
|
103
|
-
project(':fidel-react-native').projectDir = new File(rootProject.projectDir, '../node_modules/fidel-react-native/android')
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
**2.** Insert the following lines inside the dependencies block in `android/app/build.gradle`:
|
|
107
|
-
|
|
108
|
-
```java
|
|
109
|
-
implementation project(':fidel-react-native')
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
**3.** Append Jitpack to `android/build.gradle`:
|
|
113
|
-
|
|
114
|
-
```java
|
|
115
|
-
allprojects {
|
|
116
|
-
repositories {
|
|
117
|
-
...
|
|
118
|
-
maven { url "https://jitpack.io" }
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
**4.** Make sure that the `minSdkVersion` is the same or higher than the `minSdkVersion` of our native Android SDK:
|
|
124
|
-
|
|
125
|
-
```java
|
|
126
|
-
buildscript {
|
|
127
|
-
ext {
|
|
128
|
-
...
|
|
129
|
-
minSdkVersion = 19
|
|
130
|
-
...
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
**5.** Only for projects initialized with **RN <= 0.59**: Open up `android/app/src/main/java/[...]/MainApplication.java`
|
|
136
|
-
|
|
137
|
-
- Add `import com.fidelreactlibrary.FidelPackage;` to the imports at the top of the file
|
|
138
|
-
- Add `new FidelPackage()` to the list returned by the `getPackages()` method:
|
|
139
|
-
|
|
140
|
-
```java
|
|
141
|
-
protected List <ReactPackage> getPackages() {
|
|
142
|
-
return Arrays.<ReactPackage>asList(
|
|
143
|
-
new MainReactPackage(),
|
|
144
|
-
new FidelPackage(),
|
|
145
|
-
//you might have other Packages here as well.
|
|
146
|
-
);
|
|
147
|
-
}
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
**6.** Ensure that you have *Google Play Services* installed.
|
|
151
|
-
|
|
152
|
-
For a physical device you need to search on Google for *Google Play Services*. There will be a link that takes you to the Play Store and from there you will see a button to update it (*do not* search within the Play Store).
|
|
153
|
-
|
|
154
47
|
## How to use Fidel's React Native SDK
|
|
155
48
|
|
|
156
49
|
Import Fidel in your RN project:
|
|
@@ -246,6 +139,22 @@ Both `result` and `error` are objects that look like in the following examples:
|
|
|
246
139
|
}
|
|
247
140
|
```
|
|
248
141
|
|
|
142
|
+
## How to run the example application
|
|
143
|
+
|
|
144
|
+
1. Follow the React Native [environment setup instructions](https://reactnative.dev/docs/environment-setup). The example app is not an Expo app, so please follow the "React Native CLI Quickstart" guide.
|
|
145
|
+
2. Open the terminal in the "example" folder.
|
|
146
|
+
3. Install React Native dependencies (which include the Fidel react native library) by running `yarn` in the terminal
|
|
147
|
+
4. To run the iOS example app:
|
|
148
|
+
1. Switch to the "example/ios" folder in your terminal.
|
|
149
|
+
2. Run `pod install` to install the Cocoapods project dependencies
|
|
150
|
+
3. Open the `example.xcworkspace` in Xcode
|
|
151
|
+
4. Run the project (eventually, it should open another terminal windown that runs Metro)
|
|
152
|
+
5. To run the Android example app:
|
|
153
|
+
1. Open the "example/android" project in Android Studio.
|
|
154
|
+
2. Open a terminal window in the "example" folder.
|
|
155
|
+
3. Run the following command to start Metro: `npx react-native start`
|
|
156
|
+
4. Run the project on your preferred emulator/device.
|
|
157
|
+
|
|
249
158
|
## Options documentation
|
|
250
159
|
|
|
251
160
|
### bannerImage
|
|
@@ -272,7 +181,7 @@ Fidel.setOptions({
|
|
|
272
181
|
});
|
|
273
182
|
```
|
|
274
183
|
|
|
275
|
-
The possible options are: `.
|
|
184
|
+
The possible options are: `.canada`, `.ireland`, `.japan`, `.sweden`, `.unitedArabEmirates`, `.unitedKingdom`, `.unitedStates`. You can set one or multiple of these countries. If you don't set any allowed countries, the user will be able to choose any of the countries above. If you set only one country, the card linking screen will not show the country picker UI. Note that, when you set multiple countries, they will be displayed in the country picker UI in the order that you set them.
|
|
276
185
|
|
|
277
186
|
### supportedCardSchemes
|
|
278
187
|
|
|
@@ -439,7 +348,7 @@ If you do not set a ```privacyUrl```, the text will become _in accordance with t
|
|
|
439
348
|
|
|
440
349
|
### Consent text for the rest of the world
|
|
441
350
|
|
|
442
|
-
When you set
|
|
351
|
+
When you set Ireland, Japan , Sweden, United Arab Emirates or United Kingdom as allowed countries or the user selects one of these countries from the list, a consent text specific for these countries will be applied.
|
|
443
352
|
|
|
444
353
|
The following would be an example Terms & Conditions text for ```Cashback Inc``` (an example company):
|
|
445
354
|
|
package/android/build.gradle
CHANGED
|
@@ -10,16 +10,17 @@ buildscript {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
apply plugin: 'com.android.library'
|
|
13
|
+
apply from: 'jacoco.gradle'
|
|
13
14
|
|
|
14
15
|
android {
|
|
15
|
-
compileSdkVersion
|
|
16
|
-
buildToolsVersion "
|
|
16
|
+
compileSdkVersion 30
|
|
17
|
+
buildToolsVersion "30.0.3"
|
|
17
18
|
|
|
18
19
|
defaultConfig {
|
|
19
|
-
minSdkVersion
|
|
20
|
-
targetSdkVersion
|
|
20
|
+
minSdkVersion 21
|
|
21
|
+
targetSdkVersion 30
|
|
21
22
|
versionCode 1
|
|
22
|
-
versionName "1.0"
|
|
23
|
+
versionName "1.5.0"
|
|
23
24
|
}
|
|
24
25
|
lintOptions {
|
|
25
26
|
abortOnError false
|
|
@@ -38,11 +39,10 @@ repositories {
|
|
|
38
39
|
|
|
39
40
|
dependencies {
|
|
40
41
|
implementation 'com.facebook.react:react-native:+'
|
|
41
|
-
implementation 'com.github.FidelLimited:android-sdk:1.
|
|
42
|
+
implementation 'com.github.FidelLimited:android-sdk:1.6.0'
|
|
42
43
|
|
|
43
|
-
testImplementation 'junit:junit:4.
|
|
44
|
-
testImplementation 'androidx.test.ext:junit:1.1.
|
|
45
|
-
testImplementation 'org.assertj:assertj-core:
|
|
46
|
-
testImplementation 'org.robolectric:robolectric:4.
|
|
44
|
+
testImplementation 'junit:junit:4.13.2'
|
|
45
|
+
testImplementation 'androidx.test.ext:junit:1.1.2'
|
|
46
|
+
testImplementation 'org.assertj:assertj-core:3.13.2'
|
|
47
|
+
testImplementation 'org.robolectric:robolectric:4.5.1'
|
|
47
48
|
}
|
|
48
|
-
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
apply plugin: 'jacoco'
|
|
2
|
+
|
|
3
|
+
jacoco {
|
|
4
|
+
toolVersion = "0.8.6"
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
tasks.withType(Test) {
|
|
8
|
+
jacoco.includeNoLocationClasses = true
|
|
9
|
+
jacoco.excludes = ['jdk.internal.*']
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
project.afterEvaluate {
|
|
13
|
+
def buildTypes = android.buildTypes.collect { type -> type.name }
|
|
14
|
+
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
|
|
15
|
+
|
|
16
|
+
if (!productFlavors) productFlavors.add('')
|
|
17
|
+
|
|
18
|
+
productFlavors.each { productFlavorName ->
|
|
19
|
+
buildTypes.each { buildTypeName ->
|
|
20
|
+
def testTaskName = "test${buildTypeName.capitalize()}UnitTest"
|
|
21
|
+
|
|
22
|
+
task "${testTaskName}JacocoCoverage" (type:JacocoReport, dependsOn: "$testTaskName") {
|
|
23
|
+
group = "Reporting"
|
|
24
|
+
description = "Generate Jacoco coverage reports on the ${buildTypeName.capitalize()} build."
|
|
25
|
+
|
|
26
|
+
def excludes = ['**/R.class', '**/R$*.class', '**/BuildConfig.*', '**/Manifest*.*', '**/*Test*.*', 'android/**/*.*' ]
|
|
27
|
+
|
|
28
|
+
def coverageSourceDirs = [
|
|
29
|
+
"src/main/java",
|
|
30
|
+
"src/$productFlavorName/java",
|
|
31
|
+
"src/$buildTypeName/java"
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
// java compiled classes
|
|
35
|
+
def javaTree = fileTree(dir: "$buildDir/intermediates/javac/$buildTypeName/classes", excludes: excludes)
|
|
36
|
+
// kotlin compiled classes (to be used in the future)
|
|
37
|
+
def kotlinTree = fileTree(dir: "$buildDir/tmp/kotlin-classes/$buildTypeName", excludes: excludes)
|
|
38
|
+
classDirectories.from = files([javaTree, kotlinTree])
|
|
39
|
+
additionalSourceDirs.from = files(coverageSourceDirs)
|
|
40
|
+
sourceDirectories.from = files(coverageSourceDirs)
|
|
41
|
+
executionData.from = files("${buildDir}/jacoco/${testTaskName}.exec")
|
|
42
|
+
|
|
43
|
+
reports {
|
|
44
|
+
xml.enabled = true
|
|
45
|
+
html.enabled = true
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -3,7 +3,7 @@ package com.fidelreactlibrary;
|
|
|
3
3
|
|
|
4
4
|
import android.app.Activity;
|
|
5
5
|
import com.facebook.react.bridge.Callback;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
6
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
7
|
import com.facebook.react.bridge.ReactContextBaseJavaModule;
|
|
8
8
|
import com.facebook.react.bridge.ReactMethod;
|
|
9
9
|
import com.facebook.react.bridge.ReadableMap;
|
|
@@ -30,7 +30,7 @@ public class FidelModule extends ReactContextBaseJavaModule {
|
|
|
30
30
|
private final DataProcessor<ReadableMap> setupProcessor;
|
|
31
31
|
private final DataProcessor<ReadableMap> optionsProcessor;
|
|
32
32
|
private final List<ConstantsProvider> constantsProviderList;
|
|
33
|
-
private ReactApplicationContext reactContext;
|
|
33
|
+
private final ReactApplicationContext reactContext;
|
|
34
34
|
|
|
35
35
|
public FidelModule(ReactApplicationContext reactContext,
|
|
36
36
|
DataProcessor<ReadableMap> setupProcessor,
|
|
@@ -50,6 +50,16 @@ public class FidelModule extends ReactContextBaseJavaModule {
|
|
|
50
50
|
return "NativeFidelBridge";
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
@ReactMethod
|
|
54
|
+
public void addListener(String eventName) {
|
|
55
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@ReactMethod
|
|
59
|
+
public void removeListeners(Integer count) {
|
|
60
|
+
// Keep: Required for RN built in Event Emitter Calls.
|
|
61
|
+
}
|
|
62
|
+
|
|
53
63
|
@ReactMethod
|
|
54
64
|
public void openForm(Callback callback) {
|
|
55
65
|
final Activity activity = getCurrentActivity();
|
|
@@ -15,6 +15,7 @@ public final class FidelCountryAdapter implements CountryAdapter {
|
|
|
15
15
|
|
|
16
16
|
private static final String UNITED_KINGDOM_COUNTRY_KEY = "unitedKingdom";
|
|
17
17
|
private static final String UNITED_STATES_COUNTRY_KEY = "unitedStates";
|
|
18
|
+
private static final String UNITED_ARAB_EMIRATES_KEY = "unitedArabEmirates";
|
|
18
19
|
private static final String JAPAN_COUNTRY_KEY = "japan";
|
|
19
20
|
private static final String SWEDEN_COUNTRY_KEY = "sweden";
|
|
20
21
|
private static final String IRELAND_COUNTRY_KEY = "ireland";
|
|
@@ -26,6 +27,7 @@ public final class FidelCountryAdapter implements CountryAdapter {
|
|
|
26
27
|
switch (country) {
|
|
27
28
|
case UNITED_KINGDOM: return UNITED_KINGDOM_COUNTRY_KEY;
|
|
28
29
|
case UNITED_STATES: return UNITED_STATES_COUNTRY_KEY;
|
|
30
|
+
case UNITED_ARAB_EMIRATES: return UNITED_ARAB_EMIRATES_KEY;
|
|
29
31
|
case JAPAN: return JAPAN_COUNTRY_KEY;
|
|
30
32
|
case SWEDEN: return SWEDEN_COUNTRY_KEY;
|
|
31
33
|
case IRELAND: return IRELAND_COUNTRY_KEY;
|
package/android/src/main/java/com/fidelreactlibrary/events/CallbackActivityEventListener.java
CHANGED
|
@@ -17,8 +17,8 @@ public final class CallbackActivityEventListener
|
|
|
17
17
|
extends BaseActivityEventListener
|
|
18
18
|
implements CallbackInput, FidelCardLinkingObserver {
|
|
19
19
|
|
|
20
|
-
private DataConverter<Object, WritableMap> linkResultConverter;
|
|
21
|
-
private DataProcessor<WritableMap> errorHandler;
|
|
20
|
+
private final DataConverter<Object, WritableMap> linkResultConverter;
|
|
21
|
+
private final DataProcessor<WritableMap> errorHandler;
|
|
22
22
|
private Callback callback;
|
|
23
23
|
|
|
24
24
|
public CallbackActivityEventListener(DataConverter<Object, WritableMap> linkResultConverter,
|
|
@@ -27,10 +27,6 @@ public final class CallbackActivityEventListener
|
|
|
27
27
|
this.errorHandler = errorHandler;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
public CallbackActivityEventListener() {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
30
|
@Override
|
|
35
31
|
public void onActivityResult(Activity activity,
|
|
36
32
|
int requestCode,
|
|
@@ -6,6 +6,7 @@ import com.facebook.react.bridge.JavaOnlyMap;
|
|
|
6
6
|
import com.facebook.react.bridge.WritableMap;
|
|
7
7
|
import com.fidel.sdk.Fidel;
|
|
8
8
|
import com.fidel.sdk.LinkResult;
|
|
9
|
+
import com.fidel.sdk.LinkResultError;
|
|
9
10
|
import com.fidel.sdk.LinkResultErrorCode;
|
|
10
11
|
import com.fidelreactlibrary.events.CallbackActivityEventListener;
|
|
11
12
|
import com.fidelreactlibrary.fakes.CallbackSpy;
|
|
@@ -34,6 +35,9 @@ public class CallbackActivityEventListenerTests {
|
|
|
34
35
|
|
|
35
36
|
private static final String RESULT_EXTRA_KEY = Fidel.FIDEL_LINK_CARD_RESULT_CARD;
|
|
36
37
|
private static final int REQUEST_CODE = Fidel.FIDEL_LINK_CARD_REQUEST_CODE;
|
|
38
|
+
private static final LinkResultError testLinkResultError
|
|
39
|
+
= new LinkResultError(LinkResultErrorCode.INVALID_URL, "Test message", "some date");
|
|
40
|
+
private static final LinkResult testLinkResult = new LinkResult("TEST CARD ID");
|
|
37
41
|
|
|
38
42
|
@Before
|
|
39
43
|
public final void setUp() {
|
|
@@ -45,7 +49,7 @@ public class CallbackActivityEventListenerTests {
|
|
|
45
49
|
|
|
46
50
|
activity = Robolectric.buildActivity(Activity.class).setup().get();
|
|
47
51
|
intent = new IntentMock<>(activity, Activity.class);
|
|
48
|
-
intent.parcelableExtraToReturn =
|
|
52
|
+
intent.parcelableExtraToReturn = testLinkResult;
|
|
49
53
|
linkResultConverterStub.convertedDataToReturn = new JavaOnlyMap();
|
|
50
54
|
}
|
|
51
55
|
|
|
@@ -96,10 +100,34 @@ public class CallbackActivityEventListenerTests {
|
|
|
96
100
|
assertNull(intent.parcelableExtraNameAskedFor);
|
|
97
101
|
}
|
|
98
102
|
|
|
103
|
+
@Test
|
|
104
|
+
public void test_WhenCardLinkingFails_SendConvertedLinkResultToErrorHandler() {
|
|
105
|
+
sut.onCardLinkingFailed(testLinkResultError);
|
|
106
|
+
assertEquals(linkResultConverterStub.convertedDataToReturn, errorHandlerSpy.dataToProcess);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Test
|
|
110
|
+
public void test_WhenCardLinkingFails_ConvertTheErrorToWritableMap() {
|
|
111
|
+
sut.onCardLinkingFailed(testLinkResultError);
|
|
112
|
+
assertEquals(linkResultConverterStub.dataReceived, testLinkResultError);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@Test
|
|
116
|
+
public void test_WhenCardLinkingSucceeds_DoNotCallErrorHandler() {
|
|
117
|
+
sut.onCardLinkingSucceeded(testLinkResult);
|
|
118
|
+
assertNull(errorHandlerSpy.dataToProcess);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
@Test
|
|
122
|
+
public void test_WhenCardLinkingSucceeds_DoNotCallCallback() {
|
|
123
|
+
sut.onCardLinkingSucceeded(testLinkResult);
|
|
124
|
+
assertNull(callbackSpy.receivedErrorMap);
|
|
125
|
+
assertNull(callbackSpy.receivedResultMap);
|
|
126
|
+
}
|
|
127
|
+
|
|
99
128
|
private void onActivityResultWithError() {
|
|
100
129
|
LinkResultErrorCode errorCode = LinkResultErrorCode.USER_CANCELED;
|
|
101
|
-
intent.parcelableExtraToReturn = new LinkResult(errorCode, "Test error message")
|
|
102
|
-
|
|
130
|
+
intent.parcelableExtraToReturn = new LinkResult(errorCode, "Test error message", "2021-05-19T12:37:55.278Z");
|
|
103
131
|
sut.onActivityResult(activity, REQUEST_CODE, 0, intent);
|
|
104
132
|
}
|
|
105
133
|
}
|
|
@@ -7,6 +7,7 @@ import com.fidelreactlibrary.adapters.FidelCardSchemesAdapter;
|
|
|
7
7
|
|
|
8
8
|
import org.junit.Test;
|
|
9
9
|
|
|
10
|
+
import java.util.Arrays;
|
|
10
11
|
import java.util.EnumSet;
|
|
11
12
|
import java.util.HashMap;
|
|
12
13
|
import java.util.Map;
|
|
@@ -14,10 +15,10 @@ import java.util.Set;
|
|
|
14
15
|
|
|
15
16
|
import javax.annotation.Nonnull;
|
|
16
17
|
|
|
17
|
-
import
|
|
18
|
-
|
|
18
|
+
import static org.hamcrest.MatcherAssert.assertThat;
|
|
19
19
|
import static org.hamcrest.core.IsCollectionContaining.hasItem;
|
|
20
|
-
import static org.junit.Assert
|
|
20
|
+
import static org.junit.Assert.assertEquals;
|
|
21
|
+
import static org.junit.Assert.assertNull;
|
|
21
22
|
|
|
22
23
|
public final class FidelCardSchemesAdapterTests {
|
|
23
24
|
private static final String CARD_SCHEMES_KEY = "CardScheme";
|
|
@@ -25,7 +26,7 @@ public final class FidelCardSchemesAdapterTests {
|
|
|
25
26
|
private static final String MASTERCARD_SCHEME_KEY = "mastercard";
|
|
26
27
|
private static final String AMEX_SCHEME_KEY = "americanExpress";
|
|
27
28
|
|
|
28
|
-
private FidelCardSchemesAdapter sut = new FidelCardSchemesAdapter();
|
|
29
|
+
private final FidelCardSchemesAdapter sut = new FidelCardSchemesAdapter();
|
|
29
30
|
|
|
30
31
|
//Test to expose correct card scheme keys
|
|
31
32
|
@Test
|
|
@@ -78,8 +78,8 @@ public class WritableMapDataConverterTests {
|
|
|
78
78
|
JSONObject jsonField = (JSONObject)field.get(linkResult);
|
|
79
79
|
assertMapEqualsWithJSONObject(mapField.toHashMap(), jsonField);
|
|
80
80
|
}
|
|
81
|
-
else if (field.getType() != Parcelable.Creator.class && field.getType() != LinkResultError.class) {
|
|
82
|
-
fail("Some of the link result properties are not converted");
|
|
81
|
+
else if (field.getType() != Parcelable.Creator.class && field.getType() != LinkResultError.class && !field.getName().equals("$jacocoData")) {
|
|
82
|
+
fail("Some of the link result properties are not converted" + field + " field name: " + field.getName());
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
}
|
|
@@ -87,8 +87,7 @@ public class WritableMapDataConverterTests {
|
|
|
87
87
|
@Test
|
|
88
88
|
public void test_WhenConvertingLinkResultWithError_IncludeAllErrorFields() throws IllegalAccessException {
|
|
89
89
|
LinkResultErrorCode errorCode = LinkResultErrorCode.USER_CANCELED;
|
|
90
|
-
|
|
91
|
-
LinkResult linkResult = new LinkResult(errorCode, errorMessage);
|
|
90
|
+
LinkResult linkResult = new LinkResult(errorCode, TEST_ERROR_MESSAGE, "2021-05-19T12:37:55.278Z");
|
|
92
91
|
Object objectToConvert = linkResult.getError();
|
|
93
92
|
|
|
94
93
|
WritableMap receivedMap = sut.getConvertedDataFor(objectToConvert);
|
|
@@ -99,13 +98,14 @@ public class WritableMapDataConverterTests {
|
|
|
99
98
|
assertEquals(receivedString, field.get(objectToConvert));
|
|
100
99
|
}
|
|
101
100
|
else if (field.getType() == LinkResultErrorCode.class) {
|
|
102
|
-
String
|
|
101
|
+
String displayFieldName = field.getName() == "errorCode" ? "code" : field.getName();
|
|
102
|
+
String receivedErrorCodeString = receivedMap.getString(displayFieldName);
|
|
103
103
|
LinkResultErrorCode expectedErrorCode = (LinkResultErrorCode) field.get(objectToConvert);
|
|
104
104
|
String expectedErrorCodeString = expectedErrorCode.toString().toLowerCase();
|
|
105
|
-
assertEquals(
|
|
105
|
+
assertEquals(expectedErrorCodeString, receivedErrorCodeString);
|
|
106
106
|
}
|
|
107
|
-
else {
|
|
108
|
-
fail("Some of the link result
|
|
107
|
+
else if (!field.getName().equals("$jacocoData")) {
|
|
108
|
+
fail("Some of the link result properties are not converted" + field + " field name: " + field.getName());
|
|
109
109
|
}
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
sdk=28
|
package/ios/FLRNOptionsAdapter.m
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
#import "FLRNCardSchemesAdapter.h"
|
|
19
19
|
#import "RCTConvert+Options.h"
|
|
20
20
|
|
|
21
|
-
#define FLCountryValues @{@"unitedKingdom" : @(FLCountryUnitedKingdom), @"ireland" : @(FLCountryIreland), @"unitedStates" : @(FLCountryUnitedStates), @"sweden" : @(FLCountrySweden), @"japan" : @(FLCountryJapan), @"canada" : @(FLCountryCanada)}
|
|
21
|
+
#define FLCountryValues @{@"unitedArabEmirates" : @(FLCountryUnitedArabEmirates), @"unitedKingdom" : @(FLCountryUnitedKingdom), @"ireland" : @(FLCountryIreland), @"unitedStates" : @(FLCountryUnitedStates), @"sweden" : @(FLCountrySweden), @"japan" : @(FLCountryJapan), @"canada" : @(FLCountryCanada)}
|
|
22
22
|
|
|
23
23
|
@interface FLRNOptionsAdapter()
|
|
24
24
|
|
package/package.json
CHANGED
package/android/.project
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
-
<projectDescription>
|
|
3
|
-
<name>android</name>
|
|
4
|
-
<comment>Project android created by Buildship.</comment>
|
|
5
|
-
<projects>
|
|
6
|
-
</projects>
|
|
7
|
-
<buildSpec>
|
|
8
|
-
<buildCommand>
|
|
9
|
-
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
|
|
10
|
-
<arguments>
|
|
11
|
-
</arguments>
|
|
12
|
-
</buildCommand>
|
|
13
|
-
</buildSpec>
|
|
14
|
-
<natures>
|
|
15
|
-
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
|
|
16
|
-
</natures>
|
|
17
|
-
</projectDescription>
|