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.
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 +653 -0
  10. package/android/src/main/java/com/judopay/judokit/reactnative/JudoActivityEventListener.kt +49 -0
  11. package/android/src/main/java/com/judopay/judokit/reactnative/JudoKitReactNativeModule.kt +238 -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 +268 -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 +267 -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 +50 -0
  64. package/src/judo-kit/index.ts +262 -0
  65. package/src/types/index.ts +53 -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,475 +0,0 @@
1
- //
2
- // NSDictionaryConvertTests.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 "NSDictionary+JudoConvert.h"
27
-
28
- @interface NSDictionaryConvertTests : XCTestCase
29
-
30
- @end
31
-
32
- @implementation NSDictionaryConvertTests
33
-
34
- /*
35
- * GIVEN: a [NSDictionary] value should be extracted from an NSDictionary
36
- *
37
- * WHEN: the value is missing
38
- *
39
- * THEN: then an error should be thrown
40
- */
41
- - (void)test_OnMissingDictionary_ThrowError {
42
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
43
- XCTAssertThrows([mockDictionary dictionaryForKey:@"example-key"]);
44
- }
45
-
46
- /*
47
- * GIVEN: a [NSDictionary] value should be extracted from an NSDictionary
48
- *
49
- * WHEN: the value is of incorrect type
50
- *
51
- * THEN: then an error should be thrown
52
- */
53
- - (void)test_OnInvalidDictionary_ThrowError {
54
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
55
- mockDictionary[@"example-key"] = @"hello";
56
- XCTAssertThrows([mockDictionary dictionaryForKey:@"example-key"]);
57
- }
58
-
59
- /*
60
- * GIVEN: a [NSDictionary] value should be extracted from an NSDictionary
61
- *
62
- * WHEN: the value is a valid NSDictionary
63
- *
64
- * THEN: then the method should return the NSDictionary
65
- */
66
- - (void)test_OnValidDictionary_ReturnDictionary {
67
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
68
- mockDictionary[@"example-key"] = @{};
69
- XCTAssertNotNil([mockDictionary dictionaryForKey:@"example-key"]);
70
- XCTAssertTrue([[mockDictionary dictionaryForKey:@"example-key"] isKindOfClass:NSDictionary.class]);
71
- }
72
-
73
- /*
74
- * GIVEN: an optional [NSDictionary] value should be extracted from an NSDictionary
75
- *
76
- * WHEN: the value is missing
77
- *
78
- * THEN: the method should return nil
79
- */
80
- - (void)test_OnMissingOptionalDictionary_ReturnNil {
81
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
82
- XCTAssertNil([mockDictionary optionalDictionaryForKey:@"example-key"]);
83
- }
84
-
85
- /*
86
- * GIVEN: an optional [NSDictionary] value should be extracted from an NSDictionary
87
- *
88
- * WHEN: the value is of incorrect type
89
- *
90
- * THEN: then an error should be thrown
91
- */
92
- - (void)test_OnInvalidOptionalDictionary_ThrowError {
93
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
94
- mockDictionary[@"example-key"] = @"hello";
95
- XCTAssertThrows([mockDictionary optionalDictionaryForKey:@"example-key"]);
96
- }
97
-
98
- /*
99
- * GIVEN: a [NSDictionary] value should be extracted from an NSDictionary
100
- *
101
- * WHEN: the value is a valid NSDictionary
102
- *
103
- * THEN: then the method should return the NSDictionary
104
- */
105
- - (void)test_OnValidOptionalDictionary_ReturnDictionary {
106
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
107
- mockDictionary[@"example-key"] = @{};
108
- XCTAssertNotNil([mockDictionary optionalDictionaryForKey:@"example-key"]);
109
- XCTAssertTrue([[mockDictionary optionalDictionaryForKey:@"example-key"] isKindOfClass:NSDictionary.class]);
110
- }
111
-
112
- /*
113
- * GIVEN: a [NSArray] value should be extracted from an NSDictionary
114
- *
115
- * WHEN: the value is missing
116
- *
117
- * THEN: then an error should be thrown
118
- */
119
- - (void)test_OnMissingArray_ThrowError {
120
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
121
- XCTAssertThrows([mockDictionary arrayForKey:@"example-key"]);
122
- }
123
-
124
- /*
125
- * GIVEN: a [NSArray] value should be extracted from an NSDictionary
126
- *
127
- * WHEN: the value is of incorrect type
128
- *
129
- * THEN: then an error should be thrown
130
- */
131
- - (void)test_OnInvalidArray_ThrowError {
132
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
133
- mockDictionary[@"example-key"] = @"hello";
134
- XCTAssertThrows([mockDictionary arrayForKey:@"example-key"]);
135
- }
136
-
137
- /*
138
- * GIVEN: a [NSArray] value should be extracted from an NSDictionary
139
- *
140
- * WHEN: the value is a valid NSArray
141
- *
142
- * THEN: then the method should return the NSArray
143
- */
144
- - (void)test_OnValidArray_ReturnArray {
145
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
146
- mockDictionary[@"example-key"] = @[];
147
- XCTAssertNotNil([mockDictionary arrayForKey:@"example-key"]);
148
- XCTAssertTrue([[mockDictionary arrayForKey:@"example-key"] isKindOfClass:NSArray.class]);
149
- }
150
-
151
- /*
152
- * GIVEN: an optional [NSArray] value should be extracted from an NSDictionary
153
- *
154
- * WHEN: the value is missing
155
- *
156
- * THEN: the method should return nil
157
- */
158
- - (void)test_OnMissingOptionalArray_ReturnNil {
159
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
160
- XCTAssertNil([mockDictionary optionalArrayForKey:@"example-key"]);
161
- }
162
-
163
- /*
164
- * GIVEN: an optional [NSArray] value should be extracted from an NSDictionary
165
- *
166
- * WHEN: the value is of incorrect type
167
- *
168
- * THEN: then an error should be thrown
169
- */
170
- - (void)test_OnInvalidOptionalArray_ThrowError {
171
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
172
- mockDictionary[@"example-key"] = @"hello";
173
- XCTAssertThrows([mockDictionary optionalArrayForKey:@"example-key"]);
174
- }
175
-
176
- /*
177
- * GIVEN: a [NSArray] value should be extracted from an NSDictionary
178
- *
179
- * WHEN: the value is a valid NSArray
180
- *
181
- * THEN: then the method should return the NSArray
182
- */
183
- - (void)test_OnValidOptionalArray_ReturnArray {
184
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
185
- mockDictionary[@"example-key"] = @[];
186
- XCTAssertNotNil([mockDictionary optionalArrayForKey:@"example-key"]);
187
- XCTAssertTrue([[mockDictionary optionalArrayForKey:@"example-key"] isKindOfClass:NSArray.class]);
188
- }
189
-
190
- /*
191
- * GIVEN: a [NSString] value should be extracted from an NSDictionary
192
- *
193
- * WHEN: the value is missing
194
- *
195
- * THEN: then an error should be thrown
196
- */
197
- - (void)test_OnMissingString_ThrowError {
198
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
199
- XCTAssertThrows([mockDictionary stringForKey:@"example-key"]);
200
- }
201
-
202
- /*
203
- * GIVEN: a [NSString] value should be extracted from an NSDictionary
204
- *
205
- * WHEN: the value is of incorrect type
206
- *
207
- * THEN: then an error should be thrown
208
- */
209
- - (void)test_OnInvalidString_ThrowError {
210
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
211
- mockDictionary[@"example-key"] = @123;
212
- XCTAssertThrows([mockDictionary stringForKey:@"example-key"]);
213
- }
214
-
215
- /*
216
- * GIVEN: a [NSString] value should be extracted from an NSDictionary
217
- *
218
- * WHEN: the value is a valid NSString
219
- *
220
- * THEN: then the method should return the NSString
221
- */
222
- - (void)test_OnValidString_ReturnString {
223
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
224
- mockDictionary[@"example-key"] = @"hello";
225
- XCTAssertNotNil([mockDictionary stringForKey:@"example-key"]);
226
- XCTAssertTrue([[mockDictionary stringForKey:@"example-key"] isKindOfClass:NSString.class]);
227
- }
228
-
229
- /*
230
- * GIVEN: an optional [NSString] value should be extracted from an NSDictionary
231
- *
232
- * WHEN: the value is missing
233
- *
234
- * THEN: the method should return nil
235
- */
236
- - (void)test_OnMissingOptionalString_ReturnNil {
237
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
238
- XCTAssertNil([mockDictionary optionalStringForKey:@"example-key"]);
239
- }
240
-
241
- /*
242
- * GIVEN: an optional [NSString] value should be extracted from an NSDictionary
243
- *
244
- * WHEN: the value is of incorrect type
245
- *
246
- * THEN: then an error should be thrown
247
- */
248
- - (void)test_OnInvalidOptionalString_ThrowError {
249
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
250
- mockDictionary[@"example-key"] = @123;
251
- XCTAssertThrows([mockDictionary optionalStringForKey:@"example-key"]);
252
- }
253
-
254
- /*
255
- * GIVEN: a [NSString] value should be extracted from an NSDictionary
256
- *
257
- * WHEN: the value is a valid NSString
258
- *
259
- * THEN: then the method should return the NSString
260
- */
261
- - (void)test_OnValidOptionalString_ReturnString {
262
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
263
- mockDictionary[@"example-key"] = @"hello";
264
- XCTAssertNotNil([mockDictionary optionalStringForKey:@"example-key"]);
265
- XCTAssertTrue([[mockDictionary optionalStringForKey:@"example-key"] isKindOfClass:NSString.class]);
266
- }
267
-
268
- /*
269
- * GIVEN: a [NSNumber] value should be extracted from an NSDictionary
270
- *
271
- * WHEN: the value is missing
272
- *
273
- * THEN: then an error should be thrown
274
- */
275
- - (void)test_OnMissingNumber_ThrowError {
276
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
277
- XCTAssertThrows([mockDictionary numberForKey:@"example-key"]);
278
- }
279
-
280
- /*
281
- * GIVEN: a [NSNumber] value should be extracted from an NSDictionary
282
- *
283
- * WHEN: the value is of incorrect type
284
- *
285
- * THEN: then an error should be thrown
286
- */
287
- - (void)test_OnInvalidNumber_ThrowError {
288
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
289
- mockDictionary[@"example-key"] = @"hello";
290
- XCTAssertThrows([mockDictionary numberForKey:@"example-key"]);
291
- }
292
-
293
- /*
294
- * GIVEN: a [NSNumber] value should be extracted from an NSDictionary
295
- *
296
- * WHEN: the value is a valid NSNumber
297
- *
298
- * THEN: then the method should return the NSNumber
299
- */
300
- - (void)test_OnValidNumber_ReturnNumber {
301
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
302
- mockDictionary[@"example-key"] = @123.12;
303
- XCTAssertNotNil([mockDictionary numberForKey:@"example-key"]);
304
- XCTAssertTrue([[mockDictionary numberForKey:@"example-key"] isKindOfClass:NSNumber.class]);
305
- }
306
-
307
- /*
308
- * GIVEN: an optional [NSNumber] value should be extracted from an NSDictionary
309
- *
310
- * WHEN: the value is missing
311
- *
312
- * THEN: the method should return nil
313
- */
314
- - (void)test_OnMissingOptionalNumber_ReturnNil {
315
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
316
- XCTAssertNil([mockDictionary optionalNumberForKey:@"example-key"]);
317
- }
318
-
319
- /*
320
- * GIVEN: an optional [NSNumber] value should be extracted from an NSDictionary
321
- *
322
- * WHEN: the value is of incorrect type
323
- *
324
- * THEN: then an error should be thrown
325
- */
326
- - (void)test_OnInvalidOptionalNumber_ThrowError {
327
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
328
- mockDictionary[@"example-key"] = @"hello";
329
- XCTAssertThrows([mockDictionary optionalNumberForKey:@"example-key"]);
330
- }
331
-
332
- /*
333
- * GIVEN: a [NSNumber] value should be extracted from an NSDictionary
334
- *
335
- * WHEN: the value is a valid NSNumber
336
- *
337
- * THEN: then the method should return the NSNumber
338
- */
339
- - (void)test_OnValidOptionalNumber_ReturnNumber {
340
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
341
- mockDictionary[@"example-key"] = @123.12;
342
- XCTAssertNotNil([mockDictionary optionalNumberForKey:@"example-key"]);
343
- XCTAssertTrue([[mockDictionary optionalNumberForKey:@"example-key"] isKindOfClass:NSNumber.class]);
344
- }
345
-
346
- /*
347
- * GIVEN: a [Bool] value should be extracted from an NSDictionary
348
- *
349
- * WHEN: the value is missing
350
- *
351
- * THEN: then an error should be thrown
352
- */
353
- - (void)test_OnMissingBool_ThrowError {
354
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
355
- XCTAssertThrows([mockDictionary boolForKey:@"example-key"]);
356
- }
357
-
358
- /*
359
- * GIVEN: a [Bool] value should be extracted from an NSDictionary
360
- *
361
- * WHEN: the value is of incorrect type
362
- *
363
- * THEN: then an error should be thrown
364
- */
365
- - (void)test_OnInvalidBool_ThrowError {
366
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
367
- mockDictionary[@"example-key"] = @"hello";
368
- XCTAssertThrows([mockDictionary boolForKey:@"example-key"]);
369
- }
370
-
371
- /*
372
- * GIVEN: a [Bool] value should be extracted from an NSDictionary
373
- *
374
- * WHEN: the value is a valid Bool
375
- *
376
- * THEN: then the method should return the Bool
377
- */
378
- - (void)test_OnValidBool_ReturnBool {
379
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
380
- mockDictionary[@"example-key"] = @YES;
381
- XCTAssertTrue([mockDictionary boolForKey:@"example-key"]);
382
- }
383
-
384
- /*
385
- * GIVEN: an optional [Bool] value should be extracted from an NSDictionary
386
- *
387
- * WHEN: the value is missing
388
- *
389
- * THEN: the method should return nil
390
- */
391
- - (void)test_OnMissingOptionalBool_ReturnNil {
392
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
393
- XCTAssertNil([mockDictionary optionalBoolForKey:@"example-key"]);
394
- }
395
-
396
- /*
397
- * GIVEN: an optional [Bool] value should be extracted from an NSDictionary
398
- *
399
- * WHEN: the value is of incorrect type
400
- *
401
- * THEN: then an error should be thrown
402
- */
403
- - (void)test_OnInvalidOptionalBool_ThrowError {
404
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
405
- mockDictionary[@"example-key"] = @"hello";
406
- XCTAssertThrows([mockDictionary optionalBoolForKey:@"example-key"]);
407
- }
408
-
409
- /*
410
- * GIVEN: a [Bool] value should be extracted from an NSDictionary
411
- *
412
- * WHEN: the value is a valid Bool
413
- *
414
- * THEN: then the method should return the Bool
415
- */
416
- - (void)test_OnValidOptionalBool_ReturnBool {
417
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
418
- mockDictionary[@"example-key"] = @YES;
419
- XCTAssertTrue([mockDictionary optionalBoolForKey:@"example-key"]);
420
- }
421
-
422
- /*
423
- * GIVEN: a [HEX NSString] value should be extracted from an NSDictionary
424
- *
425
- * WHEN: the value is missing
426
- *
427
- * THEN: then an error should be thrown
428
- */
429
- - (void)test_OnMissingHEXString_ThrowError {
430
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
431
- mockDictionary[@"example-key"] = [NSNull new];
432
- XCTAssertThrows([mockDictionary hexColorForKey:@"example-key"]);
433
- }
434
-
435
- /*
436
- * GIVEN: a [HEX NSString] value should be extracted from an NSDictionary
437
- *
438
- * WHEN: the value is of incorrect type
439
- *
440
- * THEN: then an error should be thrown
441
- */
442
- - (void)test_OnInvalidHEXString_ThrowError {
443
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
444
- mockDictionary[@"example-key"] = @123;
445
- XCTAssertThrows([mockDictionary hexColorForKey:@"example-key"]);
446
- }
447
-
448
- /*
449
- * GIVEN: a [HEX NSString] value should be extracted from an NSDictionary
450
- *
451
- * WHEN: the value is not a valid HEX value
452
- *
453
- * THEN: then an error should be thrown
454
- */
455
- - (void)test_OnInvalidHEXStringValue_ThrowError {
456
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
457
- mockDictionary[@"example-key"] = @"hello";
458
- XCTAssertThrows([mockDictionary hexColorForKey:@"example-key"]);
459
- }
460
-
461
- /*
462
- * GIVEN: a [HEX NSString] value should be extracted from an NSDictionary
463
- *
464
- * WHEN: the value is a valid HEX NSString
465
- *
466
- * THEN: then the method should return the HEX NSString
467
- */
468
- - (void)test_OnValidHEXString_ReturnHEXString {
469
- NSMutableDictionary *mockDictionary = [NSMutableDictionary new];
470
- mockDictionary[@"example-key"] = @"#FFFFFF";
471
- XCTAssertNotNil([mockDictionary hexColorForKey:@"example-key"]);
472
- XCTAssertTrue([[mockDictionary hexColorForKey:@"example-key"] isKindOfClass:NSString.class]);
473
- }
474
-
475
- @end