@rebilly/framepay-react 4.0.6 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/build/index.d.ts +1 -1
- package/build/index.spec.js +1 -1
- package/build/lib/components/elements/applepay-element.js +2 -2
- package/build/lib/components/elements/bank-element.js +3 -3
- package/build/lib/components/elements/base-element.js +14 -13
- package/build/lib/components/elements/card-element.js +3 -3
- package/build/lib/components/elements/googlepay-element.js +2 -2
- package/build/lib/components/elements/iban-element.js +4 -4
- package/build/lib/components/elements/paypal-element.js +2 -2
- package/build/lib/components/injector.js +20 -20
- package/build/lib/components/provider.js +11 -11
- package/build/lib/constants.js +1 -1
- package/build/lib/context.js +2 -4
- package/build/lib/dom-util.js +1 -5
- package/build/lib/framepay-error.d.ts +1 -1
- package/build/lib/framepay-error.js +4 -4
- package/build/lib/get-rebilly-api.js +2 -2
- package/package.json +6 -16
- package/src/index.spec.ts +1 -1
- package/src/index.ts +3 -3
- package/src/lib/components/elements/applepay-element.tsx +2 -2
- package/src/lib/components/elements/bank-element.spec.tsx +12 -12
- package/src/lib/components/elements/bank-element.tsx +4 -4
- package/src/lib/components/elements/base-element.tsx +16 -16
- package/src/lib/components/elements/card-element.spec.tsx +13 -13
- package/src/lib/components/elements/card-element.tsx +4 -4
- package/src/lib/components/elements/googlepay-element.tsx +2 -2
- package/src/lib/components/elements/iban-element.spec.tsx +9 -9
- package/src/lib/components/elements/iban-element.tsx +4 -4
- package/src/lib/components/elements/paypal-element.tsx +2 -2
- package/src/lib/components/injector.spec.tsx +3 -4
- package/src/lib/components/injector.tsx +50 -48
- package/src/lib/components/provider.spec.tsx +5 -7
- package/src/lib/components/provider.tsx +15 -15
- package/src/lib/constants.ts +1 -1
- package/src/lib/context.ts +1 -3
- package/src/lib/dom-util.ts +0 -4
- package/src/lib/framepay-error.ts +9 -6
- package/src/lib/get-rebilly-api.ts +1 -1
- package/test/e2e/cypress-support.js +1 -1
- package/test/e2e/fixtures/apple-pay.js +4 -8
- package/test/e2e/fixtures/bank-separate.js +68 -67
- package/test/e2e/fixtures/card-separate-brands.js +256 -139
- package/test/e2e/fixtures/card-separate-rebilly-fields.js +48 -57
- package/test/e2e/fixtures/card-separate.js +214 -112
- package/test/e2e/fixtures/checkout-combined.js +145 -95
- package/test/e2e/fixtures/google-pay.js +6 -10
- package/test/e2e/fixtures/iban.js +47 -45
- package/test/e2e/fixtures/multiple-methods.js +104 -98
- package/test/e2e/fixtures/nav.js +3 -4
- package/test/e2e/fixtures/paypal.js +5 -12
- package/test/e2e/fixtures/util.js +50 -37
- package/test/e2e/specs/card-separate-brands.cy.ts +2 -2
- package/test/e2e/specs/react-version.cy.ts +1 -1
- package/test/e2e/switch-react-version.js +5 -6
- package/test/unit/jest.config.js +18 -28
- package/test/unit/specs/declaration-mock.spec.tsx +1 -0
- package/tslint.json +0 -36
|
@@ -21,32 +21,32 @@ const defaultEvents = () => ({
|
|
|
21
21
|
onReady: false,
|
|
22
22
|
onChange: false,
|
|
23
23
|
onFocus: false,
|
|
24
|
-
onBlur: false
|
|
24
|
+
onBlur: false,
|
|
25
25
|
},
|
|
26
26
|
bankAccountType: {
|
|
27
27
|
onReady: false,
|
|
28
28
|
onChange: false,
|
|
29
29
|
onFocus: false,
|
|
30
|
-
onBlur: false
|
|
30
|
+
onBlur: false,
|
|
31
31
|
},
|
|
32
32
|
bankAccountNumber: {
|
|
33
33
|
onReady: false,
|
|
34
34
|
onChange: false,
|
|
35
35
|
onFocus: false,
|
|
36
|
-
onBlur: false
|
|
36
|
+
onBlur: false,
|
|
37
37
|
},
|
|
38
38
|
bankRoutingNumber: {
|
|
39
39
|
onReady: false,
|
|
40
40
|
onChange: false,
|
|
41
41
|
onFocus: false,
|
|
42
|
-
onBlur: false
|
|
42
|
+
onBlur: false,
|
|
43
43
|
},
|
|
44
44
|
iban: {
|
|
45
45
|
onReady: false,
|
|
46
46
|
onChange: false,
|
|
47
47
|
onFocus: false,
|
|
48
|
-
onBlur: false
|
|
49
|
-
}
|
|
48
|
+
onBlur: false,
|
|
49
|
+
},
|
|
50
50
|
});
|
|
51
51
|
|
|
52
52
|
class PaymentFormComponent extends Component {
|
|
@@ -58,14 +58,14 @@ class PaymentFormComponent extends Component {
|
|
|
58
58
|
card: 'payment-card',
|
|
59
59
|
bank: 'ach',
|
|
60
60
|
iban: 'ach',
|
|
61
|
-
googlepay: 'googlepay'
|
|
61
|
+
googlepay: 'googlepay',
|
|
62
62
|
},
|
|
63
63
|
paymentElement: 'card',
|
|
64
64
|
billingAddress: {
|
|
65
65
|
firstName: 'first-name-value',
|
|
66
66
|
lastName: 'last-name-value',
|
|
67
|
-
country: 'GB'
|
|
68
|
-
}
|
|
67
|
+
country: 'GB',
|
|
68
|
+
},
|
|
69
69
|
};
|
|
70
70
|
this.handleSubmit = this.handleSubmit.bind(this);
|
|
71
71
|
}
|
|
@@ -78,22 +78,22 @@ class PaymentFormComponent extends Component {
|
|
|
78
78
|
*
|
|
79
79
|
*/
|
|
80
80
|
const billingAddress = {
|
|
81
|
-
...this.state.billingAddress
|
|
81
|
+
...this.state.billingAddress,
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
this.props.Rebilly.createToken(this.formNode, {
|
|
85
85
|
// method: this.state.paymentElements[this.state.paymentElement],
|
|
86
|
-
billingAddress
|
|
86
|
+
billingAddress,
|
|
87
87
|
})
|
|
88
|
-
.then(data => {
|
|
88
|
+
.then((data) => {
|
|
89
89
|
this.props.onEvent({
|
|
90
90
|
token: {
|
|
91
91
|
error: false,
|
|
92
|
-
data: { ...data, method: data.method }
|
|
93
|
-
}
|
|
92
|
+
data: { ...data, method: data.method },
|
|
93
|
+
},
|
|
94
94
|
});
|
|
95
95
|
})
|
|
96
|
-
.catch(err => {
|
|
96
|
+
.catch((err) => {
|
|
97
97
|
this.props.onEvent({ token: { error: true, data: err } });
|
|
98
98
|
});
|
|
99
99
|
}
|
|
@@ -110,13 +110,13 @@ class PaymentFormComponent extends Component {
|
|
|
110
110
|
events: {
|
|
111
111
|
...defaultEvents(),
|
|
112
112
|
},
|
|
113
|
-
})
|
|
114
|
-
}
|
|
113
|
+
});
|
|
114
|
+
};
|
|
115
115
|
|
|
116
116
|
return (
|
|
117
117
|
<div className="example-2">
|
|
118
118
|
<ul>
|
|
119
|
-
{elements.map(element => (
|
|
119
|
+
{elements.map((element) => (
|
|
120
120
|
<li key={`payment-method-${element}`}>
|
|
121
121
|
<button
|
|
122
122
|
id={`set-active-element-${element}`}
|
|
@@ -130,7 +130,7 @@ class PaymentFormComponent extends Component {
|
|
|
130
130
|
</ul>
|
|
131
131
|
<form
|
|
132
132
|
id="form"
|
|
133
|
-
ref={node => (this.formNode = node)}
|
|
133
|
+
ref={(node) => (this.formNode = node)}
|
|
134
134
|
method="post"
|
|
135
135
|
onSubmit={this.handleSubmit}
|
|
136
136
|
>
|
|
@@ -143,11 +143,11 @@ class PaymentFormComponent extends Component {
|
|
|
143
143
|
defaultValue={
|
|
144
144
|
this.state.billingAddress.firstName
|
|
145
145
|
}
|
|
146
|
-
onChange={e => {
|
|
146
|
+
onChange={(e) => {
|
|
147
147
|
this.props.onEvent({
|
|
148
148
|
billingAddress: {
|
|
149
|
-
firstName: e.target.value
|
|
150
|
-
}
|
|
149
|
+
firstName: e.target.value,
|
|
150
|
+
},
|
|
151
151
|
});
|
|
152
152
|
}}
|
|
153
153
|
/>
|
|
@@ -160,11 +160,11 @@ class PaymentFormComponent extends Component {
|
|
|
160
160
|
defaultValue={
|
|
161
161
|
this.state.billingAddress.lastName
|
|
162
162
|
}
|
|
163
|
-
onChange={e => {
|
|
163
|
+
onChange={(e) => {
|
|
164
164
|
this.props.onEvent({
|
|
165
165
|
billingAddress: {
|
|
166
|
-
lastName: e.target.value
|
|
167
|
-
}
|
|
166
|
+
lastName: e.target.value,
|
|
167
|
+
},
|
|
168
168
|
});
|
|
169
169
|
}}
|
|
170
170
|
/>
|
|
@@ -176,34 +176,34 @@ class PaymentFormComponent extends Component {
|
|
|
176
176
|
onReady={() =>
|
|
177
177
|
this.props.onEvent({
|
|
178
178
|
events: {
|
|
179
|
-
card: { onReady: true }
|
|
180
|
-
}
|
|
179
|
+
card: { onReady: true },
|
|
180
|
+
},
|
|
181
181
|
})
|
|
182
182
|
}
|
|
183
|
-
onChange={data =>
|
|
183
|
+
onChange={(data) =>
|
|
184
184
|
this.props.onEvent({
|
|
185
185
|
events: {
|
|
186
186
|
card: {
|
|
187
187
|
onChange: {
|
|
188
188
|
...data,
|
|
189
|
-
error: data.error || ''
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
}
|
|
189
|
+
error: data.error || '',
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
193
|
})
|
|
194
194
|
}
|
|
195
195
|
onFocus={() =>
|
|
196
196
|
this.props.onEvent({
|
|
197
197
|
events: {
|
|
198
|
-
card: { onFocus: true }
|
|
199
|
-
}
|
|
198
|
+
card: { onFocus: true },
|
|
199
|
+
},
|
|
200
200
|
})
|
|
201
201
|
}
|
|
202
202
|
onBlur={() =>
|
|
203
203
|
this.props.onEvent({
|
|
204
204
|
events: {
|
|
205
|
-
card: { onBlur: true }
|
|
206
|
-
}
|
|
205
|
+
card: { onBlur: true },
|
|
206
|
+
},
|
|
207
207
|
})
|
|
208
208
|
}
|
|
209
209
|
/>
|
|
@@ -223,12 +223,12 @@ class PaymentFormComponent extends Component {
|
|
|
223
223
|
this.props.onEvent({
|
|
224
224
|
events: {
|
|
225
225
|
bankAccountType: {
|
|
226
|
-
onReady: true
|
|
227
|
-
}
|
|
228
|
-
}
|
|
226
|
+
onReady: true,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
229
|
})
|
|
230
230
|
}
|
|
231
|
-
onChange={data =>
|
|
231
|
+
onChange={(data) =>
|
|
232
232
|
this.props.onEvent({
|
|
233
233
|
events: {
|
|
234
234
|
bankAccountType: {
|
|
@@ -236,28 +236,28 @@ class PaymentFormComponent extends Component {
|
|
|
236
236
|
...data,
|
|
237
237
|
error:
|
|
238
238
|
data.error ||
|
|
239
|
-
''
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
239
|
+
'',
|
|
240
|
+
},
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
243
|
})
|
|
244
244
|
}
|
|
245
245
|
onFocus={() =>
|
|
246
246
|
this.props.onEvent({
|
|
247
247
|
events: {
|
|
248
248
|
bankAccountType: {
|
|
249
|
-
onFocus: true
|
|
250
|
-
}
|
|
251
|
-
}
|
|
249
|
+
onFocus: true,
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
252
|
})
|
|
253
253
|
}
|
|
254
254
|
onBlur={() =>
|
|
255
255
|
this.props.onEvent({
|
|
256
256
|
events: {
|
|
257
257
|
bankAccountType: {
|
|
258
|
-
onBlur: true
|
|
259
|
-
}
|
|
260
|
-
}
|
|
258
|
+
onBlur: true,
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
261
|
})
|
|
262
262
|
}
|
|
263
263
|
/>
|
|
@@ -272,12 +272,12 @@ class PaymentFormComponent extends Component {
|
|
|
272
272
|
this.props.onEvent({
|
|
273
273
|
events: {
|
|
274
274
|
bankRoutingNumber: {
|
|
275
|
-
onReady: true
|
|
276
|
-
}
|
|
277
|
-
}
|
|
275
|
+
onReady: true,
|
|
276
|
+
},
|
|
277
|
+
},
|
|
278
278
|
})
|
|
279
279
|
}
|
|
280
|
-
onChange={data =>
|
|
280
|
+
onChange={(data) =>
|
|
281
281
|
this.props.onEvent({
|
|
282
282
|
events: {
|
|
283
283
|
bankRoutingNumber: {
|
|
@@ -285,28 +285,28 @@ class PaymentFormComponent extends Component {
|
|
|
285
285
|
...data,
|
|
286
286
|
error:
|
|
287
287
|
data.error ||
|
|
288
|
-
''
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
}
|
|
288
|
+
'',
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
292
|
})
|
|
293
293
|
}
|
|
294
294
|
onFocus={() =>
|
|
295
295
|
this.props.onEvent({
|
|
296
296
|
events: {
|
|
297
297
|
bankRoutingNumber: {
|
|
298
|
-
onFocus: true
|
|
299
|
-
}
|
|
300
|
-
}
|
|
298
|
+
onFocus: true,
|
|
299
|
+
},
|
|
300
|
+
},
|
|
301
301
|
})
|
|
302
302
|
}
|
|
303
303
|
onBlur={() =>
|
|
304
304
|
this.props.onEvent({
|
|
305
305
|
events: {
|
|
306
306
|
bankRoutingNumber: {
|
|
307
|
-
onBlur: true
|
|
308
|
-
}
|
|
309
|
-
}
|
|
307
|
+
onBlur: true,
|
|
308
|
+
},
|
|
309
|
+
},
|
|
310
310
|
})
|
|
311
311
|
}
|
|
312
312
|
/>
|
|
@@ -321,12 +321,12 @@ class PaymentFormComponent extends Component {
|
|
|
321
321
|
this.props.onEvent({
|
|
322
322
|
events: {
|
|
323
323
|
bankAccountNumber: {
|
|
324
|
-
onReady: true
|
|
325
|
-
}
|
|
326
|
-
}
|
|
324
|
+
onReady: true,
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
327
|
})
|
|
328
328
|
}
|
|
329
|
-
onChange={data =>
|
|
329
|
+
onChange={(data) =>
|
|
330
330
|
this.props.onEvent({
|
|
331
331
|
events: {
|
|
332
332
|
bankAccountNumber: {
|
|
@@ -334,28 +334,28 @@ class PaymentFormComponent extends Component {
|
|
|
334
334
|
...data,
|
|
335
335
|
error:
|
|
336
336
|
data.error ||
|
|
337
|
-
''
|
|
338
|
-
}
|
|
339
|
-
}
|
|
340
|
-
}
|
|
337
|
+
'',
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
341
|
})
|
|
342
342
|
}
|
|
343
343
|
onFocus={() =>
|
|
344
344
|
this.props.onEvent({
|
|
345
345
|
events: {
|
|
346
346
|
bankAccountNumber: {
|
|
347
|
-
onFocus: true
|
|
348
|
-
}
|
|
349
|
-
}
|
|
347
|
+
onFocus: true,
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
350
|
})
|
|
351
351
|
}
|
|
352
352
|
onBlur={() =>
|
|
353
353
|
this.props.onEvent({
|
|
354
354
|
events: {
|
|
355
355
|
bankAccountNumber: {
|
|
356
|
-
onBlur: true
|
|
357
|
-
}
|
|
358
|
-
}
|
|
356
|
+
onBlur: true,
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
359
|
})
|
|
360
360
|
}
|
|
361
361
|
/>
|
|
@@ -374,12 +374,12 @@ class PaymentFormComponent extends Component {
|
|
|
374
374
|
this.props.onEvent({
|
|
375
375
|
events: {
|
|
376
376
|
iban: {
|
|
377
|
-
onReady: true
|
|
378
|
-
}
|
|
379
|
-
}
|
|
377
|
+
onReady: true,
|
|
378
|
+
},
|
|
379
|
+
},
|
|
380
380
|
})
|
|
381
381
|
}
|
|
382
|
-
onChange={data =>
|
|
382
|
+
onChange={(data) =>
|
|
383
383
|
this.props.onEvent({
|
|
384
384
|
events: {
|
|
385
385
|
iban: {
|
|
@@ -387,28 +387,28 @@ class PaymentFormComponent extends Component {
|
|
|
387
387
|
...data,
|
|
388
388
|
error:
|
|
389
389
|
data.error ||
|
|
390
|
-
''
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
390
|
+
'',
|
|
391
|
+
},
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
394
|
})
|
|
395
395
|
}
|
|
396
396
|
onFocus={() =>
|
|
397
397
|
this.props.onEvent({
|
|
398
398
|
events: {
|
|
399
399
|
iban: {
|
|
400
|
-
onFocus: true
|
|
401
|
-
}
|
|
402
|
-
}
|
|
400
|
+
onFocus: true,
|
|
401
|
+
},
|
|
402
|
+
},
|
|
403
403
|
})
|
|
404
404
|
}
|
|
405
405
|
onBlur={() =>
|
|
406
406
|
this.props.onEvent({
|
|
407
407
|
events: {
|
|
408
408
|
iban: {
|
|
409
|
-
onBlur: true
|
|
410
|
-
}
|
|
411
|
-
}
|
|
409
|
+
onBlur: true,
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
412
|
})
|
|
413
413
|
}
|
|
414
414
|
/>
|
|
@@ -433,31 +433,37 @@ class App extends Component {
|
|
|
433
433
|
super(props);
|
|
434
434
|
this.state = {
|
|
435
435
|
events: {
|
|
436
|
-
...defaultEvents()
|
|
436
|
+
...defaultEvents(),
|
|
437
437
|
},
|
|
438
438
|
token: {
|
|
439
439
|
error: null,
|
|
440
|
-
data: null
|
|
441
|
-
}
|
|
440
|
+
data: null,
|
|
441
|
+
},
|
|
442
442
|
};
|
|
443
443
|
}
|
|
444
444
|
|
|
445
445
|
deepUpdateState(data) {
|
|
446
|
-
this.setState(prevState => {
|
|
446
|
+
this.setState((prevState) => {
|
|
447
447
|
return deepMerge(prevState, data);
|
|
448
448
|
});
|
|
449
449
|
}
|
|
450
450
|
|
|
451
451
|
render() {
|
|
452
452
|
return (
|
|
453
|
-
<FramePayProvider
|
|
453
|
+
<FramePayProvider
|
|
454
|
+
injectStyle
|
|
455
|
+
{...params}
|
|
456
|
+
onTokenReady={(token) =>
|
|
457
|
+
this.deepUpdateState({ error: false, data: token })
|
|
458
|
+
}
|
|
459
|
+
>
|
|
454
460
|
<div>
|
|
455
461
|
{ReactVersion()}
|
|
456
462
|
<div>
|
|
457
463
|
<div className="flex-wrapper">
|
|
458
464
|
{prettyDebugRender(this.state)}
|
|
459
465
|
<PaymentForm
|
|
460
|
-
onEvent={data => this.deepUpdateState(data)}
|
|
466
|
+
onEvent={(data) => this.deepUpdateState(data)}
|
|
461
467
|
/>
|
|
462
468
|
</div>
|
|
463
469
|
</div>
|
package/test/e2e/fixtures/nav.js
CHANGED
|
@@ -11,10 +11,9 @@ setTimeout(() => {
|
|
|
11
11
|
'iban',
|
|
12
12
|
'multiple-methods',
|
|
13
13
|
'paypal',
|
|
14
|
-
]
|
|
15
|
-
.
|
|
16
|
-
|
|
17
|
-
});
|
|
14
|
+
].forEach((route) => {
|
|
15
|
+
node.innerHTML += `<li><a href="/${route}.html">${route}</a></li>`;
|
|
16
|
+
});
|
|
18
17
|
|
|
19
18
|
document.body.appendChild(node);
|
|
20
19
|
}, 1000);
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import ReactDOM from 'react-dom';
|
|
3
3
|
|
|
4
|
-
import {
|
|
5
|
-
FramePayProvider,
|
|
6
|
-
withFramePayPaypalComponent
|
|
7
|
-
} from '../../../build';
|
|
4
|
+
import { FramePayProvider, withFramePayPaypalComponent } from '../../../build';
|
|
8
5
|
import { prettyDebugRender, ReactVersion } from './util';
|
|
9
6
|
import './style.css';
|
|
10
7
|
|
|
@@ -15,11 +12,10 @@ const params = {
|
|
|
15
12
|
transactionData: {
|
|
16
13
|
amount: 10,
|
|
17
14
|
currency: 'USD',
|
|
18
|
-
}
|
|
15
|
+
},
|
|
19
16
|
};
|
|
20
17
|
|
|
21
18
|
class App extends Component {
|
|
22
|
-
|
|
23
19
|
constructor(props) {
|
|
24
20
|
super(props);
|
|
25
21
|
this.state = {
|
|
@@ -35,10 +31,10 @@ class App extends Component {
|
|
|
35
31
|
onReady={() => {
|
|
36
32
|
console.log('FramePayProvider.onReady');
|
|
37
33
|
}}
|
|
38
|
-
onError={err => {
|
|
34
|
+
onError={(err) => {
|
|
39
35
|
console.log('FramePayProvider.onError', err);
|
|
40
36
|
}}
|
|
41
|
-
onTokenReady={token => this.setState({ token })}
|
|
37
|
+
onTokenReady={(token) => this.setState({ token })}
|
|
42
38
|
>
|
|
43
39
|
<div>
|
|
44
40
|
{ReactVersion()}
|
|
@@ -56,7 +52,4 @@ class App extends Component {
|
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
const WrappedApp = withFramePayPaypalComponent(App);
|
|
59
|
-
ReactDOM.render(
|
|
60
|
-
<WrappedApp />,
|
|
61
|
-
document.getElementById('app')
|
|
62
|
-
);
|
|
55
|
+
ReactDOM.render(<WrappedApp />, document.getElementById('app'));
|
|
@@ -2,26 +2,31 @@ import React from 'react';
|
|
|
2
2
|
|
|
3
3
|
export const prettyRenderState = (data, parentKey) => {
|
|
4
4
|
if (data !== null && typeof data === 'object') {
|
|
5
|
-
return
|
|
6
|
-
|
|
5
|
+
return (
|
|
6
|
+
<ul>
|
|
7
|
+
{Object.keys(data).map((key, index) => {
|
|
8
|
+
const dataKey = `${parentKey ? parentKey + '-' : ''}${key}`;
|
|
9
|
+
const value = data[key];
|
|
7
10
|
|
|
8
|
-
|
|
9
|
-
|
|
11
|
+
if (value === null) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
10
14
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
15
|
+
return (
|
|
16
|
+
<li
|
|
17
|
+
key={`state-render-${key}-${index}`}
|
|
18
|
+
id={`key-${key}`}
|
|
19
|
+
>
|
|
20
|
+
<span className="key">
|
|
21
|
+
<b>{key}</b>:
|
|
22
|
+
</span>
|
|
23
|
+
|
|
24
|
+
{prettyRenderState(value, dataKey)}
|
|
25
|
+
</li>
|
|
26
|
+
);
|
|
27
|
+
})}
|
|
28
|
+
</ul>
|
|
29
|
+
);
|
|
25
30
|
}
|
|
26
31
|
|
|
27
32
|
if (data === null) {
|
|
@@ -30,42 +35,50 @@ export const prettyRenderState = (data, parentKey) => {
|
|
|
30
35
|
|
|
31
36
|
const val = typeof data === 'object' ? JSON.stringify(data) : data;
|
|
32
37
|
|
|
33
|
-
return
|
|
34
|
-
<span
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
return (
|
|
39
|
+
<span>
|
|
40
|
+
<span id={`${parentKey}-${val}`} data-value={val} />
|
|
41
|
+
<span id={parentKey} data-value={val}>
|
|
42
|
+
{String(val)}
|
|
43
|
+
</span>
|
|
44
|
+
</span>
|
|
45
|
+
);
|
|
37
46
|
};
|
|
38
47
|
|
|
39
48
|
export const prettyDebugRender = (state) => {
|
|
40
|
-
return (
|
|
41
|
-
<div>
|
|
42
|
-
<pre id="pre">{JSON.stringify(state, null, 2)}</pre>
|
|
43
|
-
</div>
|
|
49
|
+
return (
|
|
44
50
|
<div>
|
|
45
|
-
<div
|
|
51
|
+
<div>
|
|
52
|
+
<pre id="pre">{JSON.stringify(state, null, 2)}</pre>
|
|
53
|
+
</div>
|
|
54
|
+
<div>
|
|
55
|
+
<div id="data">{prettyRenderState(state)}</div>
|
|
56
|
+
</div>
|
|
46
57
|
</div>
|
|
47
|
-
|
|
58
|
+
);
|
|
48
59
|
};
|
|
49
60
|
|
|
50
|
-
|
|
51
61
|
export const deepMerge = (target, source) => {
|
|
52
62
|
for (const key of Object.keys(source)) {
|
|
53
63
|
if (source[key] instanceof Object) {
|
|
54
64
|
source[key] = source[key] || {};
|
|
55
65
|
target[key] = target[key] || {};
|
|
56
|
-
Object.assign(
|
|
57
|
-
source[key],
|
|
58
|
-
deepMerge(target[key], source[key])
|
|
59
|
-
);
|
|
66
|
+
Object.assign(source[key], deepMerge(target[key], source[key]));
|
|
60
67
|
}
|
|
61
68
|
}
|
|
62
69
|
|
|
63
70
|
return Object.assign(target || {}, source);
|
|
64
71
|
};
|
|
65
72
|
|
|
66
|
-
|
|
67
73
|
export const ReactVersion = () => {
|
|
68
|
-
return (
|
|
69
|
-
<
|
|
70
|
-
|
|
74
|
+
return (
|
|
75
|
+
<div>
|
|
76
|
+
<h3>
|
|
77
|
+
React version:{' '}
|
|
78
|
+
<span id="react-version" data-version={React.version}>
|
|
79
|
+
{React.version}
|
|
80
|
+
</span>
|
|
81
|
+
</h3>
|
|
82
|
+
</div>
|
|
83
|
+
);
|
|
71
84
|
};
|
|
@@ -6,7 +6,7 @@ describe('card-separate-brands', () => {
|
|
|
6
6
|
it('should load the page', () => {
|
|
7
7
|
cy.title().should(
|
|
8
8
|
'eq',
|
|
9
|
-
'Test Card Page Separate Fields allowed Brands'
|
|
9
|
+
'Test Card Page Separate Fields allowed Brands',
|
|
10
10
|
);
|
|
11
11
|
});
|
|
12
12
|
|
|
@@ -58,7 +58,7 @@ describe('card-separate-brands', () => {
|
|
|
58
58
|
cy.get('#btn-update').click();
|
|
59
59
|
|
|
60
60
|
cy.get(
|
|
61
|
-
'#events-number-onChange-error-code-unavailable-card-brand'
|
|
61
|
+
'#events-number-onChange-error-code-unavailable-card-brand',
|
|
62
62
|
).should('not.exist');
|
|
63
63
|
|
|
64
64
|
cy.get('#btn-restore').click();
|
|
@@ -6,7 +6,7 @@ it(`should render with correct react version (${expectedVersion})`, () => {
|
|
|
6
6
|
cy.visit('/');
|
|
7
7
|
cy.get('#react-version')
|
|
8
8
|
.invoke('text')
|
|
9
|
-
.should(actualVersion => {
|
|
9
|
+
.should((actualVersion) => {
|
|
10
10
|
expect(actualVersion.startsWith(expectedVersion)).to.be.true;
|
|
11
11
|
});
|
|
12
12
|
});
|