judokit-react-native 4.1.2 → 4.2.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/JudoKit-ReactNative.podspec +42 -0
- package/LICENSE +1 -2
- package/README.md +106 -119
- package/android/build.gradle +65 -202
- package/android/gradle.properties +6 -1
- package/android/src/main/AndroidManifest.xml +2 -2
- package/android/src/main/AndroidManifestNew.xml +2 -0
- package/android/src/main/java/com/judopay/judokit/reactnative/Extensions.kt +382 -0
- package/android/src/main/java/com/judopay/judokit/reactnative/Helpers.kt +653 -0
- package/android/src/main/java/com/judopay/judokit/reactnative/JudoActivityEventListener.kt +49 -0
- package/android/src/main/java/com/judopay/judokit/reactnative/JudoKitReactNativeModule.kt +238 -0
- package/android/src/main/java/com/judopay/judokit/reactnative/JudoKitReactNativePackage.kt +16 -0
- package/ios/{Classes/Extensions → Extensions}/NSDictionary+JudoConvert.h +1 -1
- package/ios/{Classes/Extensions → Extensions}/NSDictionary+JudoConvert.m +2 -2
- package/ios/{Classes/Extensions → Extensions}/NSException+JudoValidationExceptions.h +1 -1
- package/ios/{Classes/Extensions → Extensions}/NSException+JudoValidationExceptions.m +1 -1
- package/ios/{Classes/Extensions → Extensions}/UIColor+RNAdditions.h +1 -1
- package/ios/{Classes/Extensions → Extensions}/UIColor+RNAdditions.m +3 -3
- package/ios/{Classes/RNJudo.h → JudoKitReactNative.h} +12 -6
- package/ios/{Classes/RNJudo.m → JudoKitReactNative.mm} +83 -81
- package/ios/{Classes/RNTypes.h → RNTypes.h} +8 -2
- package/ios/{Classes/Wrappers → Wrappers}/RNApplePayWrappers.h +1 -1
- package/ios/{Classes/Wrappers → Wrappers}/RNApplePayWrappers.m +105 -4
- package/ios/{Classes/Wrappers → Wrappers}/RNWrappers.h +14 -14
- package/ios/{Classes/Wrappers → Wrappers}/RNWrappers.m +46 -25
- package/lib/commonjs/index.js +268 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/judo-kit/index.js +212 -0
- package/lib/commonjs/judo-kit/index.js.map +1 -0
- package/lib/commonjs/types/index.js +267 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/types/judo-apple-pay-configuration.js +49 -0
- package/lib/commonjs/types/judo-apple-pay-configuration.js.map +1 -0
- package/lib/commonjs/types/judo-configuration.js +71 -0
- package/lib/commonjs/types/judo-configuration.js.map +1 -0
- package/lib/commonjs/types/judo-google-pay-configuration.js +28 -0
- package/lib/commonjs/types/judo-google-pay-configuration.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/judo-kit/index.js +205 -0
- package/lib/module/judo-kit/index.js.map +1 -0
- package/lib/module/types/index.js +8 -0
- package/lib/module/types/index.js.map +1 -0
- package/lib/module/types/judo-apple-pay-configuration.js +43 -0
- package/lib/module/types/judo-apple-pay-configuration.js.map +1 -0
- package/lib/module/types/judo-configuration.js +65 -0
- package/lib/module/types/judo-configuration.js.map +1 -0
- package/lib/module/types/judo-google-pay-configuration.js +22 -0
- package/lib/module/types/judo-google-pay-configuration.js.map +1 -0
- package/lib/typescript/src/index.d.ts +4 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/judo-kit/index.d.ts +86 -0
- package/lib/typescript/src/judo-kit/index.d.ts.map +1 -0
- package/lib/typescript/src/types/index.d.ts +4 -0
- package/lib/typescript/src/types/index.d.ts.map +1 -0
- package/lib/typescript/src/types/judo-apple-pay-configuration.d.ts +75 -0
- package/lib/typescript/src/types/judo-apple-pay-configuration.d.ts.map +1 -0
- package/lib/typescript/src/types/judo-configuration.d.ts +236 -0
- package/lib/typescript/src/types/judo-configuration.d.ts.map +1 -0
- package/lib/typescript/src/types/judo-google-pay-configuration.d.ts +42 -0
- package/lib/typescript/src/types/judo-google-pay-configuration.d.ts.map +1 -0
- package/package.json +158 -79
- package/src/index.tsx +50 -0
- package/src/judo-kit/index.ts +262 -0
- package/src/types/index.ts +53 -0
- package/src/types/judo-apple-pay-configuration.ts +85 -0
- package/src/types/judo-configuration.ts +263 -0
- package/src/types/judo-google-pay-configuration.ts +47 -0
- package/JudoPay.tsx +0 -334
- package/RNJudopay.podspec +0 -24
- package/android/src/main/java/com/reactlibrary/Extensions.kt +0 -372
- package/android/src/main/java/com/reactlibrary/Helpers.kt +0 -606
- package/android/src/main/java/com/reactlibrary/JudoReactNativeActivityEventListener.kt +0 -48
- package/android/src/main/java/com/reactlibrary/JudoReactNativeModule.kt +0 -257
- package/android/src/main/java/com/reactlibrary/JudoReactNativePBBAManager.kt +0 -52
- package/android/src/main/java/com/reactlibrary/JudoReactNativePackage.kt +0 -14
- package/components/JudoPBBAButton.ts +0 -2
- package/ios/.xcode.env +0 -11
- package/ios/Classes/Views/RNPBBAButtonManager.m +0 -42
- package/ios/Classes/Wrappers/RNPBBAWrappers.h +0 -40
- package/ios/Classes/Wrappers/RNPBBAWrappers.m +0 -57
- package/ios/Podfile +0 -44
- package/ios/Podfile.lock +0 -572
- package/ios/RNJudo.xcodeproj/project.pbxproj +0 -703
- package/ios/RNJudo.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/RNJudo.xcodeproj/xcshareddata/xcschemes/RNJudo.xcscheme +0 -97
- package/ios/RNJudo.xcworkspace/contents.xcworkspacedata +0 -10
- package/ios/RNJudoTests/Info.plist +0 -22
- package/ios/RNJudoTests/MockConfiguration.json +0 -114
- package/ios/RNJudoTests/NSDictionaryConvertTests.m +0 -475
- package/ios/RNJudoTests/RNApplePayWrappersTests.m +0 -770
- package/ios/RNJudoTests/RNJudoTests.m +0 -37
- package/ios/RNJudoTests/RNMocks.h +0 -54
- package/ios/RNJudoTests/RNMocks.m +0 -55
- package/ios/RNJudoTests/RNPBBAWrappersTests.m +0 -121
- package/ios/RNJudoTests/RNThemeTests.m +0 -576
- package/ios/RNJudoTests/RNWrappersTests.m +0 -947
- package/types/JudoApplePayTypes.tsx +0 -59
- package/types/JudoGooglePayTypes.tsx +0 -47
- package/types/JudoPBBATypes.tsx +0 -7
- package/types/JudoTypes.tsx +0 -251
|
@@ -1,770 +0,0 @@
|
|
|
1
|
-
//
|
|
2
|
-
// RNApplePayWrappersTest.m
|
|
3
|
-
// RNJudo
|
|
4
|
-
//
|
|
5
|
-
// Copyright (c) 2020 Alternative Payments Ltd
|
|
6
|
-
//
|
|
7
|
-
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
-
// of this software and associated documentation files (the "Software"), to deal
|
|
9
|
-
// in the Software without restriction, including without limitation the rights
|
|
10
|
-
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
-
// copies of the Software, and to permit persons to whom the Software is
|
|
12
|
-
// furnished to do so, subject to the following conditions:
|
|
13
|
-
//
|
|
14
|
-
// The above copyright notice and this permission notice shall be included in all
|
|
15
|
-
// copies or substantial portions of the Software.
|
|
16
|
-
//
|
|
17
|
-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
-
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
-
// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
-
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
-
// SOFTWARE.
|
|
24
|
-
|
|
25
|
-
#import <XCTest/XCTest.h>
|
|
26
|
-
#import "RNApplePayWrappers.h"
|
|
27
|
-
#import "RNMocks.h"
|
|
28
|
-
|
|
29
|
-
@interface RNApplePayWrappersTest : XCTestCase
|
|
30
|
-
|
|
31
|
-
@end
|
|
32
|
-
|
|
33
|
-
@implementation RNApplePayWrappersTest
|
|
34
|
-
|
|
35
|
-
/*
|
|
36
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
37
|
-
*
|
|
38
|
-
* WHEN: the NSDictionary is valid
|
|
39
|
-
*
|
|
40
|
-
* THEN: a configured JPApplePayConfiguration instance should be returned
|
|
41
|
-
*/
|
|
42
|
-
- (void)test_OnValidDictionary_ReturnApplePayConfiguration {
|
|
43
|
-
NSDictionary *mockConfig = RNMocks.configuration;
|
|
44
|
-
XCTAssertNotNil([RNApplePayWrappers applePayConfigurationFromConfiguration:mockConfig]);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/*
|
|
48
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
49
|
-
*
|
|
50
|
-
* WHEN: the NSDictionary has no [merchantId] property
|
|
51
|
-
*
|
|
52
|
-
* THEN: a 'missing merchant ID' exception should be thrown
|
|
53
|
-
*/
|
|
54
|
-
- (void)test_OnMissingMerchantId_ThrowError {
|
|
55
|
-
NSDictionary *config = [self configurationByChangingValue:nil forKey:@"merchantId"];
|
|
56
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/*
|
|
60
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
61
|
-
*
|
|
62
|
-
* WHEN: the [merchantId] property is not an NSString
|
|
63
|
-
*
|
|
64
|
-
* THEN: a 'invalid merchant ID' exception should be thrown
|
|
65
|
-
*/
|
|
66
|
-
- (void)test_OnInvalidMerchantId_ThrowError {
|
|
67
|
-
NSDictionary *config = [self configurationByChangingValue:@123 forKey:@"merchantId"];
|
|
68
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
/*
|
|
72
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
73
|
-
*
|
|
74
|
-
* WHEN: the NSDictionary has no [countryCode] property
|
|
75
|
-
*
|
|
76
|
-
* THEN: a 'missing country code' exception should be thrown
|
|
77
|
-
*/
|
|
78
|
-
- (void)test_OnMissingCountryCode_ThrowError {
|
|
79
|
-
NSDictionary *config = [self configurationByChangingValue:nil forKey:@"countryCode"];
|
|
80
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/*
|
|
84
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
85
|
-
*
|
|
86
|
-
* WHEN: the [merchantId] property is not a NSString
|
|
87
|
-
*
|
|
88
|
-
* THEN: a 'invalid merchant ID' exception should be thrown
|
|
89
|
-
*/
|
|
90
|
-
- (void)test_OnInvalidCountryCode_ThrowError {
|
|
91
|
-
NSDictionary *config = [self configurationByChangingValue:@123 forKey:@"countryCode"];
|
|
92
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/*
|
|
96
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
97
|
-
*
|
|
98
|
-
* WHEN: the NSDictionary has no [paymentSummaryItems] property
|
|
99
|
-
*
|
|
100
|
-
* THEN: an 'missing payment summary items' exception should be thrown
|
|
101
|
-
*/
|
|
102
|
-
- (void)test_OnMissingPaymentSummaryItems_ThrowError {
|
|
103
|
-
NSDictionary *config = [self configurationByChangingValue:nil forKey:@"paymentSummaryItems"];
|
|
104
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
/*
|
|
108
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
109
|
-
*
|
|
110
|
-
* WHEN: the [paymentSummaryItems] property is not an NSArray
|
|
111
|
-
*
|
|
112
|
-
* THEN: an 'invalid payment summary items' exception should be thrown
|
|
113
|
-
*/
|
|
114
|
-
- (void)test_OnInvalidPaymentSummaryItems_ThrowError {
|
|
115
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello" forKey:@"paymentSummaryItems"];
|
|
116
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/*
|
|
120
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
121
|
-
*
|
|
122
|
-
* WHEN: the [paymentSummaryItems] array elements are not NSDictionary types
|
|
123
|
-
*
|
|
124
|
-
* THEN: an 'invalid payment summary item elements' exception should be thrown
|
|
125
|
-
*/
|
|
126
|
-
- (void)test_OnInvalidPaymentSummaryItemElements_ThrowError {
|
|
127
|
-
NSDictionary *config = [self configurationByChangingValue:@[@"hello"] forKey:@"paymentSummaryItems"];
|
|
128
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/*
|
|
132
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
133
|
-
*
|
|
134
|
-
* WHEN: the [paymentSummaryItems] property does not have a label
|
|
135
|
-
*
|
|
136
|
-
* THEN: an 'empty payment summary items' exception should be thrown
|
|
137
|
-
*/
|
|
138
|
-
- (void)test_OnMissingPaymentSummaryItemLabel_ThrowError {
|
|
139
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
140
|
-
forKey:@"label"
|
|
141
|
-
forArrayName:@"paymentSummaryItems"];
|
|
142
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/*
|
|
146
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
147
|
-
*
|
|
148
|
-
* WHEN: the [paymentSummaryItems] label is not an NSString
|
|
149
|
-
*
|
|
150
|
-
* THEN: an 'invalid payment summary item label' exception should be thrown
|
|
151
|
-
*/
|
|
152
|
-
- (void)test_OnInvalidPaymentSummaryItemLabel_ThrowError {
|
|
153
|
-
NSDictionary *config = [self configurationByChangingValue:@123
|
|
154
|
-
forKey:@"label"
|
|
155
|
-
forArrayName:@"paymentSummaryItems"];
|
|
156
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/*
|
|
160
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
161
|
-
*
|
|
162
|
-
* WHEN: the [paymentSummaryItems] property does not have an amount
|
|
163
|
-
*
|
|
164
|
-
* THEN: a 'missing payment summary item amount' exception should be thrown
|
|
165
|
-
*/
|
|
166
|
-
- (void)test_OnMissingPaymentSummaryItemAmount_ThrowError {
|
|
167
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
168
|
-
forKey:@"amount"
|
|
169
|
-
forArrayName:@"paymentSummaryItems"];
|
|
170
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
/*
|
|
174
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
175
|
-
*
|
|
176
|
-
* WHEN: the [paymentSummaryItems] amount is not an NSString
|
|
177
|
-
*
|
|
178
|
-
* THEN: an 'invalid payment summary item amount' exception should be thrown
|
|
179
|
-
*/
|
|
180
|
-
- (void)test_OnInvalidPaymentSummaryItemAmount_ThrowError {
|
|
181
|
-
NSDictionary *config = [self configurationByChangingValue:@123
|
|
182
|
-
forKey:@"amount"
|
|
183
|
-
forArrayName:@"paymentSummaryItems"];
|
|
184
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
/*
|
|
188
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
189
|
-
*
|
|
190
|
-
* WHEN: the [paymentSummaryItems] type is not an integer
|
|
191
|
-
*
|
|
192
|
-
* THEN: an 'invalid payment summary item type' exception should be thrown
|
|
193
|
-
*/
|
|
194
|
-
- (void)test_OnInvalidPaymentSummaryItemType_ThrowError {
|
|
195
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello"
|
|
196
|
-
forKey:@"type"
|
|
197
|
-
forArrayName:@"paymentSummaryItems"];
|
|
198
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
/*
|
|
202
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
203
|
-
*
|
|
204
|
-
* WHEN: the [paymentSummaryItems] optional type is not specified
|
|
205
|
-
*
|
|
206
|
-
* THEN: the Apple Pay configuration is still initialized correctly
|
|
207
|
-
*/
|
|
208
|
-
- (void)test_OnMissingPaymentSummaryItemType_ReturnApplePayConfiguration {
|
|
209
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
210
|
-
forKey:@"type"
|
|
211
|
-
forArrayName:@"paymentSummaryItems"];
|
|
212
|
-
XCTAssertNotNil([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/*
|
|
216
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
217
|
-
*
|
|
218
|
-
* WHEN: the [merchantCapabilities] property is not an integer
|
|
219
|
-
*
|
|
220
|
-
* THEN: an 'invalid merchant capability' exception should be thrown
|
|
221
|
-
*/
|
|
222
|
-
- (void)test_OnInvalidMerchantCapabilities_ThrowError {
|
|
223
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello" forKey:@"merchantCapabilities"];
|
|
224
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
/*
|
|
228
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
229
|
-
*
|
|
230
|
-
* WHEN: the [merchantCapabilities] property is set to 0
|
|
231
|
-
*
|
|
232
|
-
* THEN: 3DS merchant capabilities should be set
|
|
233
|
-
*/
|
|
234
|
-
- (void)test_OnMerchantCapabilityValueZero_Enable3DS {
|
|
235
|
-
NSDictionary *config = [self configurationByChangingValue:@0 forKey:@"merchantCapabilities"];
|
|
236
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
237
|
-
XCTAssertEqual(appleConfig.merchantCapabilities, JPMerchantCapabilityThreeDS);
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
/*
|
|
241
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
242
|
-
*
|
|
243
|
-
* WHEN: the [merchantCapabilities] property is set to 2
|
|
244
|
-
*
|
|
245
|
-
* THEN: EMV merchant capabilities should be set
|
|
246
|
-
*/
|
|
247
|
-
- (void)test_OnMerchantCapabilityValueOne_EnableEMV {
|
|
248
|
-
NSDictionary *config = [self configurationByChangingValue:@2 forKey:@"merchantCapabilities"];
|
|
249
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
250
|
-
XCTAssertEqual(appleConfig.merchantCapabilities, JPMerchantCapabilityEMV);
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
/*
|
|
254
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
255
|
-
*
|
|
256
|
-
* WHEN: the [merchantCapabilities] property is set to 4
|
|
257
|
-
*
|
|
258
|
-
* THEN: Credit merchant capabilities should be set
|
|
259
|
-
*/
|
|
260
|
-
- (void)test_OnMerchantCapabilityValueOne_EnableCredit {
|
|
261
|
-
NSDictionary *config = [self configurationByChangingValue:@4 forKey:@"merchantCapabilities"];
|
|
262
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
263
|
-
XCTAssertEqual(appleConfig.merchantCapabilities, JPMerchantCapabilityCredit);
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/*
|
|
267
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
268
|
-
*
|
|
269
|
-
* WHEN: the [merchantCapabilities] property is set to 8
|
|
270
|
-
*
|
|
271
|
-
* THEN: Debit merchant capabilities should be set
|
|
272
|
-
*/
|
|
273
|
-
- (void)test_OnMerchantCapabilityValueOne_EnableDebit {
|
|
274
|
-
NSDictionary *config = [self configurationByChangingValue:@8 forKey:@"merchantCapabilities"];
|
|
275
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
276
|
-
XCTAssertEqual(appleConfig.merchantCapabilities, JPMerchantCapabilityDebit);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
/*
|
|
280
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
281
|
-
*
|
|
282
|
-
* WHEN: the [merchantCapabilities] property is set to 16
|
|
283
|
-
*
|
|
284
|
-
* THEN: All merchant capabilities should be set
|
|
285
|
-
*/
|
|
286
|
-
- (void)test_OnMerchantCapabilityValueOne_EnableAll {
|
|
287
|
-
NSDictionary *config = [self configurationByChangingValue:@16 forKey:@"merchantCapabilities"];
|
|
288
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
289
|
-
int value = JPMerchantCapabilityThreeDS | JPMerchantCapabilityEMV | JPMerchantCapabilityCredit | JPMerchantCapabilityDebit;
|
|
290
|
-
XCTAssertEqual(appleConfig.merchantCapabilities, value);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
/*
|
|
294
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
295
|
-
*
|
|
296
|
-
* WHEN: the [requiredBillingContactFields] property is not an integer
|
|
297
|
-
*
|
|
298
|
-
* THEN: an 'invalid required billing field' exception should be thrown
|
|
299
|
-
*/
|
|
300
|
-
- (void)test_OnInvalidRequiredBillingFields_ThrowError {
|
|
301
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello" forKey:@"requiredBillingContactFields"];
|
|
302
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
/*
|
|
306
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
307
|
-
*
|
|
308
|
-
* WHEN: the [requiredBillingContactFields] value is set to 1
|
|
309
|
-
*
|
|
310
|
-
* THEN: Postal Code must be set as a contact field
|
|
311
|
-
*/
|
|
312
|
-
- (void)test_OnRequiredBillingFieldsValueOne_SetPostalCode {
|
|
313
|
-
NSDictionary *config = [self configurationByChangingValue:@1 forKey:@"requiredBillingContactFields"];
|
|
314
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
315
|
-
XCTAssertEqual(appleConfig.requiredBillingContactFields, JPContactFieldPostalAddress);
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
/*
|
|
319
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
320
|
-
*
|
|
321
|
-
* WHEN: the [requiredBillingContactFields] value is set to 2
|
|
322
|
-
*
|
|
323
|
-
* THEN: Phone must be set as a contact field
|
|
324
|
-
*/
|
|
325
|
-
- (void)test_OnRequiredBillingFieldsValueTwo_SetPhone {
|
|
326
|
-
NSDictionary *config = [self configurationByChangingValue:@2 forKey:@"requiredBillingContactFields"];
|
|
327
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
328
|
-
XCTAssertEqual(appleConfig.requiredBillingContactFields, JPContactFieldPhone);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/*
|
|
332
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
333
|
-
*
|
|
334
|
-
* WHEN: the [requiredBillingContactFields] value is set to 4
|
|
335
|
-
*
|
|
336
|
-
* THEN: Email must be set as a contact field
|
|
337
|
-
*/
|
|
338
|
-
- (void)test_OnRequiredBillingFieldsValueFour_SetEmail {
|
|
339
|
-
NSDictionary *config = [self configurationByChangingValue:@4 forKey:@"requiredBillingContactFields"];
|
|
340
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
341
|
-
XCTAssertEqual(appleConfig.requiredBillingContactFields, JPContactFieldEmail);
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
/*
|
|
345
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
346
|
-
*
|
|
347
|
-
* WHEN: the [requiredBillingContactFields] value is set to 8
|
|
348
|
-
*
|
|
349
|
-
* THEN: Name must be set as a contact field
|
|
350
|
-
*/
|
|
351
|
-
- (void)test_OnRequiredBillingFieldsValueEight_SetName {
|
|
352
|
-
NSDictionary *config = [self configurationByChangingValue:@8 forKey:@"requiredBillingContactFields"];
|
|
353
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
354
|
-
XCTAssertEqual(appleConfig.requiredBillingContactFields, JPContactFieldName);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
/*
|
|
358
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
359
|
-
*
|
|
360
|
-
* WHEN: the [requiredBillingContactFields] value is set to 16
|
|
361
|
-
*
|
|
362
|
-
* THEN: All contact fields must be set
|
|
363
|
-
*/
|
|
364
|
-
- (void)test_OnRequiredBillingFieldsValueSixteen_SetName {
|
|
365
|
-
NSDictionary *config = [self configurationByChangingValue:@16 forKey:@"requiredBillingContactFields"];
|
|
366
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
367
|
-
XCTAssertEqual(appleConfig.requiredBillingContactFields, JPContactFieldAll);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
/*
|
|
371
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
372
|
-
*
|
|
373
|
-
* WHEN: the [requiredShippingContactFields] property is not an integer
|
|
374
|
-
*
|
|
375
|
-
* THEN: an 'invalid required shipping field' exception should be thrown
|
|
376
|
-
*/
|
|
377
|
-
- (void)test_OnInvalidRequiredShippingFields_ThrowError {
|
|
378
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello" forKey:@"requiredShippingContactFields"];
|
|
379
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
/*
|
|
383
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
384
|
-
*
|
|
385
|
-
* WHEN: the [requiredShippingContactFields] value is set to 1
|
|
386
|
-
*
|
|
387
|
-
* THEN: Postal Code must be set as a contact field
|
|
388
|
-
*/
|
|
389
|
-
- (void)test_OnRequiredShippingFieldsValueOne_SetPostalCode {
|
|
390
|
-
NSDictionary *config = [self configurationByChangingValue:@1 forKey:@"requiredShippingContactFields"];
|
|
391
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
392
|
-
XCTAssertEqual(appleConfig.requiredShippingContactFields, JPContactFieldPostalAddress);
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
/*
|
|
396
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
397
|
-
*
|
|
398
|
-
* WHEN: the [requiredShippingContactFields] value is set to 2
|
|
399
|
-
*
|
|
400
|
-
* THEN: Phone must be set as a contact field
|
|
401
|
-
*/
|
|
402
|
-
- (void)test_OnRequiredShippingFieldsValueTwo_SetPhone {
|
|
403
|
-
NSDictionary *config = [self configurationByChangingValue:@2 forKey:@"requiredShippingContactFields"];
|
|
404
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
405
|
-
XCTAssertEqual(appleConfig.requiredShippingContactFields, JPContactFieldPhone);
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/*
|
|
409
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
410
|
-
*
|
|
411
|
-
* WHEN: the [requiredShippingContactFields] value is set to 4
|
|
412
|
-
*
|
|
413
|
-
* THEN: Email must be set as a contact field
|
|
414
|
-
*/
|
|
415
|
-
- (void)test_OnRequiredShippingFieldsValueFour_SetEmail {
|
|
416
|
-
NSDictionary *config = [self configurationByChangingValue:@4 forKey:@"requiredShippingContactFields"];
|
|
417
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
418
|
-
XCTAssertEqual(appleConfig.requiredShippingContactFields, JPContactFieldEmail);
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/*
|
|
422
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
423
|
-
*
|
|
424
|
-
* WHEN: the [requiredShippingContactFields] value is set to 8
|
|
425
|
-
*
|
|
426
|
-
* THEN: Name must be set as a contact field
|
|
427
|
-
*/
|
|
428
|
-
- (void)test_OnRequiredShippingFieldsValueEight_SetName {
|
|
429
|
-
NSDictionary *config = [self configurationByChangingValue:@8 forKey:@"requiredShippingContactFields"];
|
|
430
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
431
|
-
XCTAssertEqual(appleConfig.requiredShippingContactFields, JPContactFieldName);
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/*
|
|
435
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
436
|
-
*
|
|
437
|
-
* WHEN: the [requiredShippingContactFields] value is set to 16
|
|
438
|
-
*
|
|
439
|
-
* THEN: All contact fields must be set
|
|
440
|
-
*/
|
|
441
|
-
- (void)test_OnRequiredShippingFieldsValueSixteen_SetName {
|
|
442
|
-
NSDictionary *config = [self configurationByChangingValue:@16 forKey:@"requiredShippingContactFields"];
|
|
443
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
444
|
-
XCTAssertEqual(appleConfig.requiredShippingContactFields, JPContactFieldAll);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
/*
|
|
449
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
450
|
-
*
|
|
451
|
-
* WHEN: the [shippingMethods] property is not an NSArray
|
|
452
|
-
*
|
|
453
|
-
* THEN: an 'invalid shipping method' exception should be thrown
|
|
454
|
-
*/
|
|
455
|
-
- (void)test_OnInvalidShippingMethod_ThrowError {
|
|
456
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello" forKey:@"shippingMethods"];
|
|
457
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
/*
|
|
461
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
462
|
-
*
|
|
463
|
-
* WHEN: the [shippingMethods] array elements are not of NSDictionary type
|
|
464
|
-
*
|
|
465
|
-
* THEN: an 'invalid shipping method elements' exception should be thrown
|
|
466
|
-
*/
|
|
467
|
-
- (void)test_OnInvalidShippingMethodElements_ThrowError {
|
|
468
|
-
NSDictionary *config = [self configurationByChangingValue:@[@"hello"] forKey:@"shippingMethods"];
|
|
469
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
/*
|
|
473
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
474
|
-
*
|
|
475
|
-
* WHEN: the [shippingMethods] element does not have an identifier
|
|
476
|
-
*
|
|
477
|
-
* THEN: a 'missing shipping method identifier' exception should be thrown
|
|
478
|
-
*/
|
|
479
|
-
- (void)test_OnMissingShippingMethodIdentifier_ThrowError {
|
|
480
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
481
|
-
forKey:@"identifier"
|
|
482
|
-
forArrayName:@"shippingMethods"];
|
|
483
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
/*
|
|
487
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
488
|
-
*
|
|
489
|
-
* WHEN: the [shippingMethods] element identifier is not an NSString
|
|
490
|
-
*
|
|
491
|
-
* THEN: a 'invalid shipping method identifier' exception should be thrown
|
|
492
|
-
*/
|
|
493
|
-
- (void)test_OnInvalidShippingMethodIdentifier_ThrowError {
|
|
494
|
-
NSDictionary *config = [self configurationByChangingValue:@123
|
|
495
|
-
forKey:@"identifier"
|
|
496
|
-
forArrayName:@"shippingMethods"];
|
|
497
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/*
|
|
501
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
502
|
-
*
|
|
503
|
-
* WHEN: the [shippingMethods] element does not have a detail
|
|
504
|
-
*
|
|
505
|
-
* THEN: a 'missing shipping method detail' exception should be thrown
|
|
506
|
-
*/
|
|
507
|
-
- (void)test_OnMissingShippingMethodDetail_ThrowError {
|
|
508
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
509
|
-
forKey:@"detail"
|
|
510
|
-
forArrayName:@"shippingMethods"];
|
|
511
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
512
|
-
}
|
|
513
|
-
|
|
514
|
-
/*
|
|
515
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
516
|
-
*
|
|
517
|
-
* WHEN: the [shippingMethods] element detail is not an NSString
|
|
518
|
-
*
|
|
519
|
-
* THEN: a 'invalid shipping method detail' exception should be thrown
|
|
520
|
-
*/
|
|
521
|
-
- (void)test_OnInvalidShippingMethodDetail_ThrowError {
|
|
522
|
-
NSDictionary *config = [self configurationByChangingValue:@123
|
|
523
|
-
forKey:@"detail"
|
|
524
|
-
forArrayName:@"shippingMethods"];
|
|
525
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
526
|
-
}
|
|
527
|
-
|
|
528
|
-
/*
|
|
529
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
530
|
-
*
|
|
531
|
-
* WHEN: the [shippingMethods] element does not have a label
|
|
532
|
-
*
|
|
533
|
-
* THEN: a 'missing shipping method label' exception should be thrown
|
|
534
|
-
*/
|
|
535
|
-
- (void)test_OnMissingShippingMethodLabel_ThrowError {
|
|
536
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
537
|
-
forKey:@"label"
|
|
538
|
-
forArrayName:@"shippingMethods"];
|
|
539
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
540
|
-
}
|
|
541
|
-
|
|
542
|
-
/*
|
|
543
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
544
|
-
*
|
|
545
|
-
* WHEN: the [shippingMethods] element label is not an NSString
|
|
546
|
-
*
|
|
547
|
-
* THEN: a 'invalid shipping method label' exception should be thrown
|
|
548
|
-
*/
|
|
549
|
-
- (void)test_OnInvalidShippingMethodLabel_ThrowError {
|
|
550
|
-
NSDictionary *config = [self configurationByChangingValue:@123
|
|
551
|
-
forKey:@"label"
|
|
552
|
-
forArrayName:@"shippingMethods"];
|
|
553
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
/*
|
|
557
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
558
|
-
*
|
|
559
|
-
* WHEN: the [shippingMethods] element does not have an amount
|
|
560
|
-
*
|
|
561
|
-
* THEN: a 'missing shipping method amount' exception should be thrown
|
|
562
|
-
*/
|
|
563
|
-
- (void)test_OnMissingShippingMethodAmount_ThrowError {
|
|
564
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
565
|
-
forKey:@"amount"
|
|
566
|
-
forArrayName:@"shippingMethods"];
|
|
567
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
/*
|
|
571
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
572
|
-
*
|
|
573
|
-
* WHEN: the [shippingMethods] element amount is not an NSString
|
|
574
|
-
*
|
|
575
|
-
* THEN: a 'invalid shipping method amount' exception should be thrown
|
|
576
|
-
*/
|
|
577
|
-
- (void)test_OnInvalidShippingMethodAmount_ThrowError {
|
|
578
|
-
NSDictionary *config = [self configurationByChangingValue:@123
|
|
579
|
-
forKey:@"amount"
|
|
580
|
-
forArrayName:@"shippingMethods"];
|
|
581
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
582
|
-
}
|
|
583
|
-
|
|
584
|
-
/*
|
|
585
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
586
|
-
*
|
|
587
|
-
* WHEN: the [shippingMethods] element does not have a type
|
|
588
|
-
*
|
|
589
|
-
* THEN: a 'missing shipping method type' exception should be thrown
|
|
590
|
-
*/
|
|
591
|
-
- (void)test_OnMissingShippingMethodType_ThrowError {
|
|
592
|
-
NSDictionary *config = [self configurationByChangingValue:nil
|
|
593
|
-
forKey:@"type"
|
|
594
|
-
forArrayName:@"shippingMethods"];
|
|
595
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
596
|
-
}
|
|
597
|
-
|
|
598
|
-
/*
|
|
599
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
600
|
-
*
|
|
601
|
-
* WHEN: the [shippingMethods] element type is not an integer
|
|
602
|
-
*
|
|
603
|
-
* THEN: a 'invalid shipping method type' exception should be thrown
|
|
604
|
-
*/
|
|
605
|
-
- (void)test_OnInvalidShippingMethodType_ThrowError {
|
|
606
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello"
|
|
607
|
-
forKey:@"type"
|
|
608
|
-
forArrayName:@"shippingMethods"];
|
|
609
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
/*
|
|
613
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
614
|
-
*
|
|
615
|
-
* WHEN: the [shippingType] property is not an integer
|
|
616
|
-
*
|
|
617
|
-
* THEN: an 'invalid shipping type' exception should be thrown
|
|
618
|
-
*/
|
|
619
|
-
- (void)test_OnInvalidShippingType_ThrowError {
|
|
620
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello" forKey:@"shippingType"];
|
|
621
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
622
|
-
}
|
|
623
|
-
|
|
624
|
-
/*
|
|
625
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
626
|
-
*
|
|
627
|
-
* WHEN: the [shippingType] integer value goes beyond the available scope
|
|
628
|
-
*
|
|
629
|
-
* THEN: an 'invalid shipping type value' exception should be thrown
|
|
630
|
-
*/
|
|
631
|
-
- (void)test_OnInvalidShippingTypeValue_ThrowError {
|
|
632
|
-
NSDictionary *config = [self configurationByChangingValue:@123 forKey:@"shippingType"];
|
|
633
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
634
|
-
}
|
|
635
|
-
|
|
636
|
-
/*
|
|
637
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
638
|
-
*
|
|
639
|
-
* WHEN: the [shippingType] value is set to 0
|
|
640
|
-
*
|
|
641
|
-
* THEN: Shipping option should be set
|
|
642
|
-
*/
|
|
643
|
-
- (void)test_OnShippingTypeValueZero_SetShipping {
|
|
644
|
-
NSDictionary *config = [self configurationByChangingValue:@0 forKey:@"shippingType"];
|
|
645
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
646
|
-
XCTAssertEqual(appleConfig.shippingType, JPShippingTypeShipping);
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/*
|
|
650
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
651
|
-
*
|
|
652
|
-
* WHEN: the [shippingType] value is set to 1
|
|
653
|
-
*
|
|
654
|
-
* THEN: Delivery option should be set
|
|
655
|
-
*/
|
|
656
|
-
- (void)test_OnShippingTypeValueOne_SetDelivery {
|
|
657
|
-
NSDictionary *config = [self configurationByChangingValue:@1 forKey:@"shippingType"];
|
|
658
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
659
|
-
XCTAssertEqual(appleConfig.shippingType, JPShippingTypeDelivery);
|
|
660
|
-
}
|
|
661
|
-
|
|
662
|
-
/*
|
|
663
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
664
|
-
*
|
|
665
|
-
* WHEN: the [shippingType] value is set to 2
|
|
666
|
-
*
|
|
667
|
-
* THEN: Store Pickup option should be set
|
|
668
|
-
*/
|
|
669
|
-
- (void)test_OnShippingTypeValueTwo_SetStorePickup {
|
|
670
|
-
NSDictionary *config = [self configurationByChangingValue:@2 forKey:@"shippingType"];
|
|
671
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
672
|
-
XCTAssertEqual(appleConfig.shippingType, JPShippingTypeStorePickup);
|
|
673
|
-
}
|
|
674
|
-
|
|
675
|
-
/*
|
|
676
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
677
|
-
*
|
|
678
|
-
* WHEN: the [shippingType] value is set to 3
|
|
679
|
-
*
|
|
680
|
-
* THEN: Service Pickup option should be set
|
|
681
|
-
*/
|
|
682
|
-
- (void)test_OnShippingTypeValueThree_SetServicePickup {
|
|
683
|
-
NSDictionary *config = [self configurationByChangingValue:@3 forKey:@"shippingType"];
|
|
684
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
685
|
-
XCTAssertEqual(appleConfig.shippingType, JPShippingTypeServicePickup);
|
|
686
|
-
}
|
|
687
|
-
|
|
688
|
-
/*
|
|
689
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
690
|
-
*
|
|
691
|
-
* WHEN: the [returnedInfo] property is not an integer
|
|
692
|
-
*
|
|
693
|
-
* THEN: an 'invalid returned info' exception should be thrown
|
|
694
|
-
*/
|
|
695
|
-
- (void)test_OnInvalidReturnedInfo_ThrowError {
|
|
696
|
-
NSDictionary *config = [self configurationByChangingValue:@"hello" forKey:@"returnedInfo"];
|
|
697
|
-
XCTAssertThrows([RNApplePayWrappers applePayConfigurationFromConfiguration:config]);
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
/*
|
|
701
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
702
|
-
*
|
|
703
|
-
* WHEN: the [returnedInfo] value is set to 1
|
|
704
|
-
*
|
|
705
|
-
* THEN: Billing return info should be set
|
|
706
|
-
*/
|
|
707
|
-
- (void)test_OnReturnedInfoValueZero_SetBilling {
|
|
708
|
-
NSDictionary *config = [self configurationByChangingValue:@1 forKey:@"returnedInfo"];
|
|
709
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
710
|
-
XCTAssertEqual(appleConfig.returnedContactInfo, JPReturnedInfoBillingContacts);
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
/*
|
|
714
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
715
|
-
*
|
|
716
|
-
* WHEN: the [returnedInfo] value is set to 2
|
|
717
|
-
*
|
|
718
|
-
* THEN: Shipping return info should be set
|
|
719
|
-
*/
|
|
720
|
-
- (void)test_OnReturnedInfoValueOne_SetShipping {
|
|
721
|
-
NSDictionary *config = [self configurationByChangingValue:@2 forKey:@"returnedInfo"];
|
|
722
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
723
|
-
XCTAssertEqual(appleConfig.returnedContactInfo, JPReturnedInfoShippingContacts);
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
/*
|
|
727
|
-
* GIVEN: a configuration NSDictionary is passed to the Apple Pay wrapper
|
|
728
|
-
*
|
|
729
|
-
* WHEN: the [returnedInfo] value is set to 3
|
|
730
|
-
*
|
|
731
|
-
* THEN: All return info should be set
|
|
732
|
-
*/
|
|
733
|
-
- (void)test_OnReturnedInfoValueOne_SetAll {
|
|
734
|
-
NSDictionary *config = [self configurationByChangingValue:@4 forKey:@"returnedInfo"];
|
|
735
|
-
JPApplePayConfiguration *appleConfig = [RNApplePayWrappers applePayConfigurationFromConfiguration:config];
|
|
736
|
-
XCTAssertEqual(appleConfig.returnedContactInfo, JPReturnedInfoAll);
|
|
737
|
-
}
|
|
738
|
-
|
|
739
|
-
#pragma mark - Helpers
|
|
740
|
-
|
|
741
|
-
- (NSMutableDictionary *)configurationByChangingValue:(id)value
|
|
742
|
-
forKey:(NSString *)key {
|
|
743
|
-
|
|
744
|
-
NSMutableDictionary *mockConfig = RNMocks.configuration;
|
|
745
|
-
NSMutableDictionary *mockAppleConfig = RNMocks.applePayConfiguration;
|
|
746
|
-
|
|
747
|
-
mockAppleConfig[key] = value;
|
|
748
|
-
mockConfig[@"applePayConfiguration"] = mockAppleConfig;
|
|
749
|
-
|
|
750
|
-
return mockConfig;
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
- (NSMutableDictionary *)configurationByChangingValue:(id)value
|
|
754
|
-
forKey:(NSString *)key
|
|
755
|
-
forArrayName:(NSString *)name {
|
|
756
|
-
|
|
757
|
-
NSMutableDictionary *mockConfig = RNMocks.configuration;
|
|
758
|
-
NSMutableDictionary *mockAppleConfig = RNMocks.applePayConfiguration;
|
|
759
|
-
|
|
760
|
-
NSArray *items = mockAppleConfig[name];
|
|
761
|
-
NSMutableDictionary *firstItem = [items.firstObject mutableCopy];
|
|
762
|
-
firstItem[key] = value;
|
|
763
|
-
|
|
764
|
-
mockAppleConfig[name] = @[firstItem];
|
|
765
|
-
mockConfig[@"applePayConfiguration"] = mockAppleConfig;
|
|
766
|
-
|
|
767
|
-
return mockConfig;
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
@end
|