judokit-react-native 4.1.3 → 4.2.1

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.
Files changed (101) hide show
  1. package/JudoKit-ReactNative.podspec +42 -0
  2. package/LICENSE +1 -2
  3. package/README.md +106 -119
  4. package/android/build.gradle +65 -202
  5. package/android/gradle.properties +6 -1
  6. package/android/src/main/AndroidManifest.xml +2 -2
  7. package/android/src/main/AndroidManifestNew.xml +2 -0
  8. package/android/src/main/java/com/judopay/judokit/reactnative/Extensions.kt +382 -0
  9. package/android/src/main/java/com/judopay/judokit/reactnative/Helpers.kt +678 -0
  10. package/android/src/main/java/com/judopay/judokit/reactnative/JudoActivityEventListener.kt +50 -0
  11. package/android/src/main/java/com/judopay/judokit/reactnative/JudoKitReactNativeModule.kt +153 -0
  12. package/android/src/main/java/com/judopay/judokit/reactnative/JudoKitReactNativePackage.kt +16 -0
  13. package/ios/{Classes/Extensions → Extensions}/NSDictionary+JudoConvert.h +1 -1
  14. package/ios/{Classes/Extensions → Extensions}/NSDictionary+JudoConvert.m +2 -2
  15. package/ios/{Classes/Extensions → Extensions}/NSException+JudoValidationExceptions.h +1 -1
  16. package/ios/{Classes/Extensions → Extensions}/NSException+JudoValidationExceptions.m +1 -1
  17. package/ios/{Classes/Extensions → Extensions}/UIColor+RNAdditions.h +1 -1
  18. package/ios/{Classes/Extensions → Extensions}/UIColor+RNAdditions.m +3 -3
  19. package/ios/{Classes/RNJudo.h → JudoKitReactNative.h} +12 -6
  20. package/ios/{Classes/RNJudo.m → JudoKitReactNative.mm} +83 -81
  21. package/ios/{Classes/RNTypes.h → RNTypes.h} +8 -2
  22. package/ios/{Classes/Wrappers → Wrappers}/RNApplePayWrappers.h +1 -1
  23. package/ios/{Classes/Wrappers → Wrappers}/RNApplePayWrappers.m +105 -4
  24. package/ios/{Classes/Wrappers → Wrappers}/RNWrappers.h +14 -14
  25. package/ios/{Classes/Wrappers → Wrappers}/RNWrappers.m +46 -25
  26. package/lib/commonjs/index.js +274 -0
  27. package/lib/commonjs/index.js.map +1 -0
  28. package/lib/commonjs/judo-kit/index.js +212 -0
  29. package/lib/commonjs/judo-kit/index.js.map +1 -0
  30. package/lib/commonjs/types/index.js +273 -0
  31. package/lib/commonjs/types/index.js.map +1 -0
  32. package/lib/commonjs/types/judo-apple-pay-configuration.js +49 -0
  33. package/lib/commonjs/types/judo-apple-pay-configuration.js.map +1 -0
  34. package/lib/commonjs/types/judo-configuration.js +71 -0
  35. package/lib/commonjs/types/judo-configuration.js.map +1 -0
  36. package/lib/commonjs/types/judo-google-pay-configuration.js +28 -0
  37. package/lib/commonjs/types/judo-google-pay-configuration.js.map +1 -0
  38. package/lib/module/index.js +6 -0
  39. package/lib/module/index.js.map +1 -0
  40. package/lib/module/judo-kit/index.js +205 -0
  41. package/lib/module/judo-kit/index.js.map +1 -0
  42. package/lib/module/types/index.js +8 -0
  43. package/lib/module/types/index.js.map +1 -0
  44. package/lib/module/types/judo-apple-pay-configuration.js +43 -0
  45. package/lib/module/types/judo-apple-pay-configuration.js.map +1 -0
  46. package/lib/module/types/judo-configuration.js +65 -0
  47. package/lib/module/types/judo-configuration.js.map +1 -0
  48. package/lib/module/types/judo-google-pay-configuration.js +22 -0
  49. package/lib/module/types/judo-google-pay-configuration.js.map +1 -0
  50. package/lib/typescript/src/index.d.ts +4 -0
  51. package/lib/typescript/src/index.d.ts.map +1 -0
  52. package/lib/typescript/src/judo-kit/index.d.ts +86 -0
  53. package/lib/typescript/src/judo-kit/index.d.ts.map +1 -0
  54. package/lib/typescript/src/types/index.d.ts +4 -0
  55. package/lib/typescript/src/types/index.d.ts.map +1 -0
  56. package/lib/typescript/src/types/judo-apple-pay-configuration.d.ts +75 -0
  57. package/lib/typescript/src/types/judo-apple-pay-configuration.d.ts.map +1 -0
  58. package/lib/typescript/src/types/judo-configuration.d.ts +236 -0
  59. package/lib/typescript/src/types/judo-configuration.d.ts.map +1 -0
  60. package/lib/typescript/src/types/judo-google-pay-configuration.d.ts +42 -0
  61. package/lib/typescript/src/types/judo-google-pay-configuration.d.ts.map +1 -0
  62. package/package.json +158 -79
  63. package/src/index.tsx +51 -0
  64. package/src/judo-kit/index.ts +262 -0
  65. package/src/types/index.ts +54 -0
  66. package/src/types/judo-apple-pay-configuration.ts +85 -0
  67. package/src/types/judo-configuration.ts +263 -0
  68. package/src/types/judo-google-pay-configuration.ts +47 -0
  69. package/JudoPay.tsx +0 -334
  70. package/RNJudopay.podspec +0 -24
  71. package/android/src/main/java/com/reactlibrary/Extensions.kt +0 -372
  72. package/android/src/main/java/com/reactlibrary/Helpers.kt +0 -606
  73. package/android/src/main/java/com/reactlibrary/JudoReactNativeActivityEventListener.kt +0 -48
  74. package/android/src/main/java/com/reactlibrary/JudoReactNativeModule.kt +0 -257
  75. package/android/src/main/java/com/reactlibrary/JudoReactNativePBBAManager.kt +0 -52
  76. package/android/src/main/java/com/reactlibrary/JudoReactNativePackage.kt +0 -14
  77. package/components/JudoPBBAButton.ts +0 -2
  78. package/ios/.xcode.env +0 -11
  79. package/ios/Classes/Views/RNPBBAButtonManager.m +0 -42
  80. package/ios/Classes/Wrappers/RNPBBAWrappers.h +0 -40
  81. package/ios/Classes/Wrappers/RNPBBAWrappers.m +0 -57
  82. package/ios/Podfile +0 -44
  83. package/ios/Podfile.lock +0 -572
  84. package/ios/RNJudo.xcodeproj/project.pbxproj +0 -703
  85. package/ios/RNJudo.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  86. package/ios/RNJudo.xcodeproj/xcshareddata/xcschemes/RNJudo.xcscheme +0 -97
  87. package/ios/RNJudo.xcworkspace/contents.xcworkspacedata +0 -10
  88. package/ios/RNJudoTests/Info.plist +0 -22
  89. package/ios/RNJudoTests/MockConfiguration.json +0 -114
  90. package/ios/RNJudoTests/NSDictionaryConvertTests.m +0 -475
  91. package/ios/RNJudoTests/RNApplePayWrappersTests.m +0 -770
  92. package/ios/RNJudoTests/RNJudoTests.m +0 -37
  93. package/ios/RNJudoTests/RNMocks.h +0 -54
  94. package/ios/RNJudoTests/RNMocks.m +0 -55
  95. package/ios/RNJudoTests/RNPBBAWrappersTests.m +0 -121
  96. package/ios/RNJudoTests/RNThemeTests.m +0 -576
  97. package/ios/RNJudoTests/RNWrappersTests.m +0 -947
  98. package/types/JudoApplePayTypes.tsx +0 -59
  99. package/types/JudoGooglePayTypes.tsx +0 -47
  100. package/types/JudoPBBATypes.tsx +0 -7
  101. package/types/JudoTypes.tsx +0 -251
@@ -1,576 +0,0 @@
1
- //
2
- // RNThemeTests.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 NONINFRINGEMENT. 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 "RNMocks.h"
27
- #import "RNWrappers.h"
28
- #import "UIColor+RNAdditions.h"
29
-
30
- @interface RNThemeTests : XCTestCase
31
-
32
- @end
33
-
34
- @implementation RNThemeTests
35
-
36
- /*
37
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
38
- *
39
- * WHEN: the [largeTitleFont] property of the [theme] dictionary is not an NSString
40
- *
41
- * THEN: an 'invalid large title font' exception should be thrown
42
- */
43
- - (void)test_OnInvalidLargeTitleFont_ThrowError {
44
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"largeTitleFont"];
45
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
46
- }
47
-
48
- /*
49
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
50
- *
51
- * WHEN: the [largeTitleSize] property of the [theme] dictionary is not an integer
52
- *
53
- * THEN: an 'invalid large title size' exception should be thrown
54
- */
55
- - (void)test_OnInvalidLargeTitleSize_ThrowError {
56
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"largeTitleSize"];
57
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
58
- }
59
-
60
- /*
61
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
62
- *
63
- * WHEN: the [titleFont] property of the [theme] dictionary is not an NSString
64
- *
65
- * THEN: an 'invalid title font' exception should be thrown
66
- */
67
- - (void)test_OnInvalidTitleFont_ThrowError {
68
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"titleFont"];
69
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
70
- }
71
-
72
- /*
73
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
74
- *
75
- * WHEN: the [titleSize] property of the [theme] dictionary is not an integer
76
- *
77
- * THEN: an 'invalid title size' exception should be thrown
78
- */
79
- - (void)test_OnInvalidTitleSize_ThrowError {
80
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"titleSize"];
81
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
82
- }
83
-
84
- /*
85
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
86
- *
87
- * WHEN: the [headlineFont] property of the [theme] dictionary is not an NSString
88
- *
89
- * THEN: an 'invalid headline font' exception should be thrown
90
- */
91
- - (void)test_OnInvalidHeadlineFont_ThrowError {
92
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"headlineFont"];
93
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
94
- }
95
-
96
- /*
97
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
98
- *
99
- * WHEN: the [headlineSize] property of the [theme] dictionary is not an integer
100
- *
101
- * THEN: an 'invalid headline size' exception should be thrown
102
- */
103
- - (void)test_OnInvalidHeadlineSize_ThrowError {
104
- NSDictionary *props = [self propertiesWithThemeValue:@"" forKey:@"headlineSize"];
105
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
106
- }
107
-
108
- /*
109
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
110
- *
111
- * WHEN: the [headlineLightFont] property of the [theme] dictionary is not an NSString
112
- *
113
- * THEN: an 'invalid headline light font' exception should be thrown
114
- */
115
- - (void)test_OnInvalidHeadlineLightFont_ThrowError {
116
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"headlineLightFont"];
117
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
118
- }
119
-
120
- /*
121
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
122
- *
123
- * WHEN: the [headlineLightSize] property of the [theme] dictionary is not an integer
124
- *
125
- * THEN: an 'invalid headline light size' exception should be thrown
126
- */
127
- - (void)test_OnInvalidHeadlineLightSize_ThrowError {
128
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"headlineLightSize"];
129
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
130
- }
131
-
132
- /*
133
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
134
- *
135
- * WHEN: the [bodyFont] property of the [theme] dictionary is not an NSString
136
- *
137
- * THEN: an 'invalid body font' exception should be thrown
138
- */
139
- - (void)test_OnInvalidBodyFont_ThrowError {
140
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"bodyFont"];
141
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
142
- }
143
-
144
- /*
145
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
146
- *
147
- * WHEN: the [bodySize] property of the [theme] dictionary is not an integer
148
- *
149
- * THEN: an 'invalid body size' exception should be thrown
150
- */
151
- - (void)test_OnInvalidBodySize_ThrowError {
152
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"bodySize"];
153
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
154
- }
155
-
156
- /*
157
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
158
- *
159
- * WHEN: the [bodyBoldFont] property of the [theme] dictionary is not an NSString
160
- *
161
- * THEN: an 'invalid body bold font' exception should be thrown
162
- */
163
- - (void)test_OnInvalidBodyBoldFont_ThrowError {
164
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"bodyBoldFont"];
165
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
166
- }
167
-
168
- /*
169
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
170
- *
171
- * WHEN: the [bodyBoldSize] property of the [theme] dictionary is not an integer
172
- *
173
- * THEN: an 'invalid body bold size' exception should be thrown
174
- */
175
- - (void)test_OnInvalidBodyBoldSize_ThrowError {
176
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"bodyBoldSize"];
177
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
178
- }
179
-
180
- /*
181
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
182
- *
183
- * WHEN: the [captionFont] property of the [theme] dictionary is not an NSString
184
- *
185
- * THEN: an 'invalid caption font' exception should be thrown
186
- */
187
- - (void)test_OnInvalidCaptionFont_ThrowError {
188
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"captionFont"];
189
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
190
- }
191
-
192
- /*
193
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
194
- *
195
- * WHEN: the [captionSize] property of the [theme] dictionary is not an integer
196
- *
197
- * THEN: an 'invalid caption size' exception should be thrown
198
- */
199
- - (void)test_OnInvalidCaptionSize_ThrowError {
200
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"captionSize"];
201
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
202
- }
203
-
204
- /*
205
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
206
- *
207
- * WHEN: the [captionBoldFont] property of the [theme] dictionary is not an NSString
208
- *
209
- * THEN: an 'invalid caption font' exception should be thrown
210
- */
211
- - (void)test_OnInvalidCaptionBoldFont_ThrowError {
212
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"captionBoldFont"];
213
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
214
- }
215
-
216
- /*
217
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
218
- *
219
- * WHEN: the [captionBoldSize] property of the [theme] dictionary is not an integer
220
- *
221
- * THEN: an 'invalid caption size' exception should be thrown
222
- */
223
- - (void)test_OnInvalidCaptionBoldSize_ThrowError {
224
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"captionBoldSize"];
225
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
226
- }
227
-
228
- /*
229
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
230
- *
231
- * WHEN: the [jpBlackColor] property of the [theme] dictionary is not an NSString
232
- *
233
- * THEN: an 'invalid JPBlack color' exception should be thrown
234
- */
235
- - (void)test_OnInvalidJPBlackColor_ThrowError {
236
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"jpBlackColor"];
237
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
238
- }
239
-
240
- /*
241
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
242
- *
243
- * WHEN: the [jpBlackColor] value is not a valid HEX format (#••••••)
244
- *
245
- * THEN: an 'invalid JPBlack color format' exception should be thrown
246
- */
247
- - (void)test_OnInvalidJPBlackColorFormat_ThrowError {
248
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"jpBlackColor"];
249
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
250
- }
251
-
252
- /*
253
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
254
- *
255
- * WHEN: the [jpBlackColor] value is a valid HEX format (#••••••)
256
- *
257
- * THEN: the JPConfiguration object should be succesfully initialized with a valid color
258
- */
259
- - (void)test_OnValidJPBlackColorFormat_ThrowError {
260
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"jpBlackColor"];
261
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
262
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
263
- XCTAssertTrue([config.uiConfiguration.theme.jpBlackColor isEqual:color]);
264
- }
265
-
266
- /*
267
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
268
- *
269
- * WHEN: the [jpDarkGrayColor] property of the [theme] dictionary is not an NSString
270
- *
271
- * THEN: an 'invalid JPDarkGray color' exception should be thrown
272
- */
273
- - (void)test_OnInvalidJPDarkGrayColor_ThrowError {
274
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"jpDarkGrayColor"];
275
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
276
- }
277
-
278
- /*
279
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
280
- *
281
- * WHEN: the [jpDarkGrayColor] value is not a valid HEX format (#••••••)
282
- *
283
- * THEN: an 'invalid JPDarkGray color format' exception should be thrown
284
- */
285
- - (void)test_OnInvalidJPDarkGrayColorFormat_ThrowError {
286
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"jpDarkGrayColor"];
287
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
288
- }
289
-
290
- /*
291
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
292
- *
293
- * WHEN: the [jpDarkGrayColor] value is a valid HEX format (#••••••)
294
- *
295
- * THEN: the JPConfiguration object should be succesfully initialized with a valid color
296
- */
297
- - (void)test_OnValidJPDarkGrayColorFormat_ThrowError {
298
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"jpDarkGrayColor"];
299
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
300
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
301
- XCTAssertTrue([config.uiConfiguration.theme.jpDarkGrayColor isEqual:color]);
302
- }
303
-
304
- /*
305
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
306
- *
307
- * WHEN: the [jpGrayColor] property of the [theme] dictionary is not an NSString
308
- *
309
- * THEN: an 'invalid JPGray color' exception should be thrown
310
- */
311
- - (void)test_OnInvalidJPGrayColor_ThrowError {
312
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"jpGrayColor"];
313
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
314
- }
315
-
316
- /*
317
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
318
- *
319
- * WHEN: the [jpGrayColor] value is not a valid HEX format (#••••••)
320
- *
321
- * THEN: an 'invalid JPGray color format' exception should be thrown
322
- */
323
- - (void)test_OnInvalidJPGrayColorFormat_ThrowError {
324
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"jpGrayColor"];
325
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
326
- }
327
-
328
- /*
329
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
330
- *
331
- * WHEN: the [jpGrayColor] value is a valid HEX format (#••••••)
332
- *
333
- * THEN: the JPConfiguration object should be succesfully initialized with a valid color
334
- */
335
- - (void)test_OnValidJPGrayColorFormat_ThrowError {
336
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"jpGrayColor"];
337
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
338
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
339
- XCTAssertTrue([config.uiConfiguration.theme.jpGrayColor isEqual:color]);
340
- }
341
-
342
- /*
343
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
344
- *
345
- * WHEN: the [jpLightGrayColor] property of the [theme] dictionary is not an NSString
346
- *
347
- * THEN: an 'invalid JPLightGray color' exception should be thrown
348
- */
349
- - (void)test_OnInvalidJPLightGrayColor_ThrowError {
350
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"jpLightGrayColor"];
351
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
352
- }
353
-
354
- /*
355
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
356
- *
357
- * WHEN: the [jpLightGrayColor] value is not a valid HEX format (#••••••)
358
- *
359
- * THEN: an 'invalid JPLightGray color format' exception should be thrown
360
- */
361
- - (void)test_OnInvalidJPLightGrayColorFormat_ThrowError {
362
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"jpLightGrayColor"];
363
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
364
- }
365
-
366
- /*
367
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
368
- *
369
- * WHEN: the [jpLightGrayColor] value is a valid HEX format (#••••••)
370
- *
371
- * THEN: the JPLightGray object should be succesfully initialized with a valid color
372
- */
373
- - (void)test_OnValidJPLightGrayColorFormat_ThrowError {
374
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"jpLightGrayColor"];
375
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
376
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
377
- XCTAssertTrue([config.uiConfiguration.theme.jpLightGrayColor isEqual:color]);
378
- }
379
-
380
- /*
381
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
382
- *
383
- * WHEN: the [jpRedColor] property of the [theme] dictionary is not an NSString
384
- *
385
- * THEN: an 'invalid JPRed color' exception should be thrown
386
- */
387
- - (void)test_OnInvalidJPRedColor_ThrowError {
388
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"jpRedColor"];
389
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
390
- }
391
-
392
- /*
393
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
394
- *
395
- * WHEN: the [jpRedColor] value is not a valid HEX format (#••••••)
396
- *
397
- * THEN: an 'invalid JPRed color format' exception should be thrown
398
- */
399
- - (void)test_OnInvalidJPRedColorFormat_ThrowError {
400
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"jpRedColor"];
401
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
402
- }
403
-
404
- /*
405
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
406
- *
407
- * WHEN: the [jpRedColor] value is a valid HEX format (#••••••)
408
- *
409
- * THEN: the JPRed object should be succesfully initialized with a valid color
410
- */
411
- - (void)test_OnValidJPRedColorFormat_ThrowError {
412
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"jpRedColor"];
413
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
414
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
415
- XCTAssertTrue([config.uiConfiguration.theme.jpRedColor isEqual:color]);
416
- }
417
-
418
- /*
419
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
420
- *
421
- * WHEN: the [jpWhiteColor] property of the [theme] dictionary is not an NSString
422
- *
423
- * THEN: an 'invalid JPWhite color' exception should be thrown
424
- */
425
- - (void)test_OnInvalidJPWhiteColor_ThrowError {
426
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"jpWhiteColor"];
427
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
428
- }
429
-
430
- /*
431
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
432
- *
433
- * WHEN: the [jpWhiteColor] value is not a valid HEX format (#••••••)
434
- *
435
- * THEN: an 'invalid JPWhite color format' exception should be thrown
436
- */
437
- - (void)test_OnInvalidJPWhiteColorFormat_ThrowError {
438
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"jpWhiteColor"];
439
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
440
- }
441
-
442
- /*
443
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
444
- *
445
- * WHEN: the [jpWhiteColor] value is a valid HEX format (#••••••)
446
- *
447
- * THEN: the JPWhite object should be succesfully initialized with a valid color
448
- */
449
- - (void)test_OnValidJPWhiteColorFormat_ThrowError {
450
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"jpWhiteColor"];
451
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
452
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
453
- XCTAssertTrue([config.uiConfiguration.theme.jpWhiteColor isEqual:color]);
454
- }
455
-
456
- /*
457
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
458
- *
459
- * WHEN: the [buttonColor] property of the [theme] dictionary is not an NSString
460
- *
461
- * THEN: an 'invalid button color' exception should be thrown
462
- */
463
- - (void)test_OnInvalidButtonColor_ThrowError {
464
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"buttonColor"];
465
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
466
- }
467
-
468
- /*
469
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
470
- *
471
- * WHEN: the [buttonColor] value is not a valid HEX format (#••••••)
472
- *
473
- * THEN: an 'invalid button color format' exception should be thrown
474
- */
475
- - (void)test_OnInvalidButtonColorFormat_ThrowError {
476
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"buttonColor"];
477
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
478
- }
479
-
480
- /*
481
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
482
- *
483
- * WHEN: the [buttonColor] value is a valid HEX format (#••••••)
484
- *
485
- * THEN: the button color should be succesfully initialized with a valid color
486
- */
487
- - (void)test_OnValidButtonColorFormat_ThrowError {
488
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"buttonColor"];
489
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
490
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
491
- XCTAssertTrue([config.uiConfiguration.theme.buttonColor isEqual:color]);
492
- }
493
-
494
- /*
495
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
496
- *
497
- * WHEN: the [buttonTitleColor] property of the [theme] dictionary is not an NSString
498
- *
499
- * THEN: an 'invalid button title color' exception should be thrown
500
- */
501
- - (void)test_OnInvalidButtonTitleColor_ThrowError {
502
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"buttonTitleColor"];
503
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
504
- }
505
-
506
- /*
507
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
508
- *
509
- * WHEN: the [buttonTitleColor] value is not a valid HEX format (#••••••)
510
- *
511
- * THEN: an 'invalid button title color format' exception should be thrown
512
- */
513
- - (void)test_OnInvalidButtonTitleColorFormat_ThrowError {
514
- NSDictionary *props = [self propertiesWithThemeValue:@"FFFFFF" forKey:@"buttonTitleColor"];
515
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
516
- }
517
-
518
- /*
519
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
520
- *
521
- * WHEN: the [buttonTitleColor] value is a valid HEX format (#••••••)
522
- *
523
- * THEN: the button title color should be succesfully initialized with a valid color
524
- */
525
- - (void)test_OnValidButtonTitleColorFormat_ThrowError {
526
- NSDictionary *props = [self propertiesWithThemeValue:@"#FFFFFF" forKey:@"buttonTitleColor"];
527
- JPConfiguration *config = [RNWrappers configurationFromProperties:props];
528
- UIColor *color = [UIColor colorFromHexString:@"#FFFFFF"];
529
- XCTAssertTrue([config.uiConfiguration.theme.buttonTitleColor isEqual:color]);
530
- }
531
-
532
- /*
533
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
534
- *
535
- * WHEN: the [backButtonImage] property of the [theme] dictionary is not an NSString
536
- *
537
- * THEN: an 'invalid back button image' exception should be thrown
538
- */
539
- - (void)test_OnInvalidBackButtonImage_ThrowError {
540
- NSDictionary *props = [self propertiesWithThemeValue:@123 forKey:@"backButtonImage"];
541
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
542
- }
543
-
544
- /*
545
- * GIVEN: a UI configuration NSDictionary is passed to the wrapper with a valid [theme] property
546
- *
547
- * WHEN: the [buttonCornerRadius] property of the [theme] dictionary is not a double
548
- *
549
- * THEN: an 'invalid button corner radius' exception should be thrown
550
- */
551
- - (void)test_OnInvalidButtonCornerRadius_ThrowError {
552
- NSDictionary *props = [self propertiesWithThemeValue:@"hello" forKey:@"buttonCornerRadius"];
553
- XCTAssertThrows([RNWrappers configurationFromProperties:props]);
554
- }
555
-
556
- #pragma mark - Helpers
557
-
558
- - (NSMutableDictionary *)propertiesWithThemeValue:(id)value
559
- forKey:(NSString *)key{
560
-
561
- NSMutableDictionary *mockProps = RNMocks.properties;
562
- NSMutableDictionary *mockConfig = RNMocks.configuration;
563
- NSMutableDictionary *uiConfiguration = [mockConfig[@"uiConfiguration"] mutableCopy];
564
- NSMutableDictionary *theme = [uiConfiguration[@"theme"] mutableCopy];
565
-
566
- theme[key] = value;
567
-
568
- uiConfiguration[@"theme"] = theme;
569
- mockConfig[@"uiConfiguration"] = uiConfiguration;
570
- mockProps[@"configuration"] = mockConfig;
571
-
572
- return mockProps;
573
- }
574
-
575
-
576
- @end