@financial-times/n-conversion-forms 24.0.0 → 25.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/.github/workflows/gh-pages-deploy.yml +1 -0
- package/build-state/npm-shrinkwrap.json +22 -6054
- package/components/__snapshots__/b2c-partnership-confirmation.spec.js.snap +1 -1
- package/components/__snapshots__/confirmation.spec.js.snap +0 -6
- package/components/__snapshots__/debug.spec.js.snap +23 -11
- package/components/b2c-partnership-confirmation.jsx +1 -1
- package/components/confirmation.jsx +13 -8
- package/components/confirmation.spec.js +1 -1
- package/components/debug.jsx +18 -11
- package/components/debug.stories.js +13 -0
- package/components/index.jsx +1 -1
- package/components/payment-term.jsx +14 -2
- package/components/text-input.jsx +73 -0
- package/components/text-input.spec.js +118 -0
- package/components/text-input.stories.js +31 -0
- package/dist/b2c-partnership-confirmation.js +1 -1
- package/dist/confirmation.js +9 -2
- package/dist/debug.js +6 -6
- package/dist/index.js +9 -9
- package/dist/payment-term.js +11 -3
- package/dist/text-input.js +84 -0
- package/main.scss +0 -2
- package/package.json +1 -1
- package/utils/payment-term.js +25 -1
- package/components/__snapshots__/b2c-partnership-payment-term.spec.js.snap +0 -193
- package/components/b2c-partnership-payment-term.jsx +0 -126
- package/components/b2c-partnership-payment-term.spec.js +0 -52
- package/components/b2c-partnership-payment-term.stories.js +0 -44
- package/dist/b2c-partnership-payment-term.js +0 -91
- package/styles/b2c-partnership-payment-term.scss +0 -20
|
@@ -7,7 +7,7 @@ exports[`B2CPartnershipConfirmation renders as default 1`] = `
|
|
|
7
7
|
</div>
|
|
8
8
|
<div class="ncf__paragraph">
|
|
9
9
|
<h1 class="ncf__header ncf__header--confirmation">
|
|
10
|
-
Welcome to your
|
|
10
|
+
Welcome to your 30 days' Premium access
|
|
11
11
|
</h1>
|
|
12
12
|
</div>
|
|
13
13
|
</div>
|
|
@@ -11,12 +11,6 @@ exports[`Confirmation renders appropriately if is B2C Partnership 1`] = `
|
|
|
11
11
|
<h1 class="ncf__header ncf__header--confirmation">
|
|
12
12
|
</h1>
|
|
13
13
|
</div>
|
|
14
|
-
<p class="ncf__paragraph">
|
|
15
|
-
We’ve sent confirmation to your email. Make sure you check your spam folder if you don’t receive it.
|
|
16
|
-
</p>
|
|
17
|
-
<p>
|
|
18
|
-
We've also sent you an email to start your 90-day All Access Digital subscription with The Washington Post.
|
|
19
|
-
</p>
|
|
20
14
|
<p class="ncf__paragraph">
|
|
21
15
|
Here’s a summary of your subscription:
|
|
22
16
|
</p>
|
|
@@ -5,7 +5,7 @@ exports[`Debug renders with default props 1`] = `""`;
|
|
|
5
5
|
exports[`Debug renders with isTest 1`] = `
|
|
6
6
|
<div class="ncf__debug-panel">
|
|
7
7
|
<span class="ncf__debug-environment">
|
|
8
|
-
<a class="ncf__button ncf__button--inverse ncf__debug-button--test"
|
|
8
|
+
<a class="ncf__button ncf__button--debug ncf__button--inverse ncf__debug-button--test"
|
|
9
9
|
onclick="setTestEnvironment('off');"
|
|
10
10
|
>
|
|
11
11
|
<strong>
|
|
@@ -30,7 +30,7 @@ exports[`Debug renders with isTest 1`] = `
|
|
|
30
30
|
GBR: 'EC4M9BT',
|
|
31
31
|
USA: '10028',
|
|
32
32
|
CAN: 'K0E 9Z9'
|
|
33
|
-
}
|
|
33
|
+
};
|
|
34
34
|
|
|
35
35
|
var debugData = {
|
|
36
36
|
billingCity: 'London',
|
|
@@ -54,9 +54,12 @@ exports[`Debug renders with isTest 1`] = `
|
|
|
54
54
|
postCode: postcodeByCountry[COUNTRY_CODE],
|
|
55
55
|
primaryTelephone: '0987654321',
|
|
56
56
|
responsibility: 'ADL',
|
|
57
|
-
|
|
57
|
+
ukVisaWorldpay: '4111111111111111',
|
|
58
58
|
usAmex: '378282246310005',
|
|
59
|
-
|
|
59
|
+
usVisaWorldpay: '4112344112344113',
|
|
60
|
+
checkoutVisa: '4242424242424242',
|
|
61
|
+
checkout3dsChallenge: 'Checkout1!',
|
|
62
|
+
chaseVisa: '4011361100000010',
|
|
60
63
|
};
|
|
61
64
|
|
|
62
65
|
function logout () {
|
|
@@ -130,6 +133,9 @@ exports[`Debug renders with isTest 1`] = `
|
|
|
130
133
|
.ncf__debug-button--production {
|
|
131
134
|
background-color: #990000;
|
|
132
135
|
}
|
|
136
|
+
.ncf__button--debug {
|
|
137
|
+
padding: 0px 5px;
|
|
138
|
+
}
|
|
133
139
|
</style>
|
|
134
140
|
`;
|
|
135
141
|
|
|
@@ -138,7 +144,7 @@ exports[`Debug renders with links 1`] = `""`;
|
|
|
138
144
|
exports[`Debug renders with showHelpers 1`] = `
|
|
139
145
|
<div class="ncf__debug-panel">
|
|
140
146
|
<span class="ncf__debug-environment">
|
|
141
|
-
<a class="ncf__button ncf__button--inverse ncf__debug-button--production"
|
|
147
|
+
<a class="ncf__button ncf__button--debug ncf__button--inverse ncf__debug-button--production"
|
|
142
148
|
onclick="setTestEnvironment('on');"
|
|
143
149
|
>
|
|
144
150
|
<strong>
|
|
@@ -148,19 +154,19 @@ exports[`Debug renders with showHelpers 1`] = `
|
|
|
148
154
|
</a>
|
|
149
155
|
</span>
|
|
150
156
|
<span class="ncf__debug-helpers">
|
|
151
|
-
<button class="ncf__button ncf__button--inverse"
|
|
157
|
+
<button class="ncf__button ncf__button--debug ncf__button--inverse"
|
|
152
158
|
onclick="logout();"
|
|
153
159
|
title="Logout and refresh"
|
|
154
160
|
>
|
|
155
161
|
Logout
|
|
156
162
|
</button>
|
|
157
|
-
<button class="ncf__button ncf__button--inverse"
|
|
163
|
+
<button class="ncf__button ncf__button--debug ncf__button--inverse"
|
|
158
164
|
onclick="fillForm();"
|
|
159
165
|
title="Fill form with debug data"
|
|
160
166
|
>
|
|
161
167
|
Fill
|
|
162
168
|
</button>
|
|
163
|
-
<button class="ncf__button ncf__button--inverse"
|
|
169
|
+
<button class="ncf__button ncf__button--debug ncf__button--inverse"
|
|
164
170
|
onclick="fillForm(); submitForm();"
|
|
165
171
|
title="Fill form with debug data and submit"
|
|
166
172
|
>
|
|
@@ -183,7 +189,7 @@ exports[`Debug renders with showHelpers 1`] = `
|
|
|
183
189
|
GBR: 'EC4M9BT',
|
|
184
190
|
USA: '10028',
|
|
185
191
|
CAN: 'K0E 9Z9'
|
|
186
|
-
}
|
|
192
|
+
};
|
|
187
193
|
|
|
188
194
|
var debugData = {
|
|
189
195
|
billingCity: 'London',
|
|
@@ -207,9 +213,12 @@ exports[`Debug renders with showHelpers 1`] = `
|
|
|
207
213
|
postCode: postcodeByCountry[COUNTRY_CODE],
|
|
208
214
|
primaryTelephone: '0987654321',
|
|
209
215
|
responsibility: 'ADL',
|
|
210
|
-
|
|
216
|
+
ukVisaWorldpay: '4111111111111111',
|
|
211
217
|
usAmex: '378282246310005',
|
|
212
|
-
|
|
218
|
+
usVisaWorldpay: '4112344112344113',
|
|
219
|
+
checkoutVisa: '4242424242424242',
|
|
220
|
+
checkout3dsChallenge: 'Checkout1!',
|
|
221
|
+
chaseVisa: '4011361100000010',
|
|
213
222
|
};
|
|
214
223
|
|
|
215
224
|
function logout () {
|
|
@@ -283,5 +292,8 @@ exports[`Debug renders with showHelpers 1`] = `
|
|
|
283
292
|
.ncf__debug-button--production {
|
|
284
293
|
background-color: #990000;
|
|
285
294
|
}
|
|
295
|
+
.ncf__button--debug {
|
|
296
|
+
padding: 0px 5px;
|
|
297
|
+
}
|
|
286
298
|
</style>
|
|
287
299
|
`;
|
|
@@ -19,7 +19,7 @@ export function B2CPartnershipConfirmation ({ ctaElement = null }) {
|
|
|
19
19
|
<div className="ncf__paragraph">
|
|
20
20
|
{
|
|
21
21
|
<h1 className="ncf__header ncf__header--confirmation">
|
|
22
|
-
{'Welcome to your
|
|
22
|
+
{'Welcome to your 30 days\' Premium access'}
|
|
23
23
|
</h1>
|
|
24
24
|
}
|
|
25
25
|
</div>
|
|
@@ -7,6 +7,7 @@ export function Confirmation ({
|
|
|
7
7
|
// isTrial prop is needed for the floodlight pixel tracking.
|
|
8
8
|
isTrial = false,
|
|
9
9
|
isB2cPartnership = false,
|
|
10
|
+
b2cPartnershipCopy = [],
|
|
10
11
|
offer = '',
|
|
11
12
|
email = EMAIL_DEFAULT_TEXT,
|
|
12
13
|
details = null,
|
|
@@ -63,15 +64,18 @@ export function Confirmation ({
|
|
|
63
64
|
</div>
|
|
64
65
|
|
|
65
66
|
{nextActionTop}
|
|
67
|
+
{!isB2cPartnership && (
|
|
68
|
+
<p className="ncf__paragraph">
|
|
69
|
+
We’ve sent confirmation to {email}. Make sure you check your spam folder
|
|
70
|
+
if you don’t receive it.
|
|
71
|
+
</p>
|
|
72
|
+
)}
|
|
66
73
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
<p>
|
|
73
|
-
We've also sent you an email to start your 90-day All Access
|
|
74
|
-
Digital subscription with The Washington Post.
|
|
74
|
+
{isB2cPartnership && b2cPartnershipCopy.length > 0 ? (
|
|
75
|
+
<p className="ncf__paragraph">
|
|
76
|
+
{b2cPartnershipCopy[0]}
|
|
77
|
+
<span className="ncf__legend">{` ${email}. `}</span>
|
|
78
|
+
{b2cPartnershipCopy[1]}
|
|
75
79
|
</p>
|
|
76
80
|
) : (
|
|
77
81
|
''
|
|
@@ -126,6 +130,7 @@ export function Confirmation ({
|
|
|
126
130
|
Confirmation.propTypes = {
|
|
127
131
|
isTrial: PropTypes.bool,
|
|
128
132
|
isB2cPartnership: PropTypes.bool,
|
|
133
|
+
b2cPartnershipCopy: PropTypes.array,
|
|
129
134
|
offer: PropTypes.string.isRequired,
|
|
130
135
|
email: PropTypes.string,
|
|
131
136
|
details: PropTypes.arrayOf(
|
|
@@ -21,7 +21,7 @@ describe('Confirmation', () => {
|
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
it('renders appropriately if is B2C Partnership', () => {
|
|
24
|
-
const props = { isB2cPartnership: true };
|
|
24
|
+
const props = { isB2cPartnership: true, b2cDiscountCopy: ['Send email'] };
|
|
25
25
|
|
|
26
26
|
expect(Confirmation).toRenderCorrectly(props);
|
|
27
27
|
});
|
package/components/debug.jsx
CHANGED
|
@@ -8,18 +8,19 @@ export function Debug ({ isTest = false, showHelpers = false, links = {} }) {
|
|
|
8
8
|
// entirely this component should be rethought.
|
|
9
9
|
const testEnvironment = `
|
|
10
10
|
<span class="ncf__debug-environment">
|
|
11
|
-
<a class="ncf__button ncf__button--inverse ncf__debug-button--test" onclick="setTestEnvironment('off');"><strong>TEST</strong> relax you are using the test API</a>
|
|
11
|
+
<a class="ncf__button ncf__button--debug ncf__button--inverse ncf__debug-button--test" onclick="setTestEnvironment('off');"><strong>TEST</strong> relax you are using the test API</a>
|
|
12
12
|
</span>
|
|
13
13
|
`;
|
|
14
14
|
const productionEnvironment = `
|
|
15
15
|
<span class="ncf__debug-environment">
|
|
16
|
-
<a class="ncf__button ncf__button--inverse ncf__debug-button--production" onclick="setTestEnvironment('on');"><strong>PRODUCTION</strong> careful you are using the production API</a>
|
|
16
|
+
<a class="ncf__button ncf__button--debug ncf__button--inverse ncf__debug-button--production" onclick="setTestEnvironment('on');"><strong>PRODUCTION</strong> careful you are using the production API</a>
|
|
17
17
|
</span>
|
|
18
18
|
`;
|
|
19
19
|
const testCards = `
|
|
20
|
-
<button id="ncf-copy-
|
|
21
|
-
<button id="ncf-copy-
|
|
22
|
-
<button id="ncf-copy-
|
|
20
|
+
<button id="ncf-copy-visa-checkout-card" class="ncf__button ncf__button--debug ncf__button--inverse" onclick="copyToClipboard('checkoutVisa');" title="Copy Checkout Visa test card number to clipboard">EU Visa (cvv:100)</button>
|
|
21
|
+
<button id="ncf-copy-visa-checkout-3ds" class="ncf__button ncf__button--debug ncf__button--inverse" onclick="copyToClipboard('checkout3dsChallenge');" title="Copy Checkout cvv number (default success) to clipboard">EU 3ds challenge</button>
|
|
22
|
+
<button id="ncf-copy-visa-chase-card" class="ncf__button ncf__button--debug ncf__button--inverse" onclick="copyToClipboard('chaseVisa');" title="Copy Chase card number to clipboard">US Visa (exp:1230,cvv:111)</button>
|
|
23
|
+
<button id="ncf-link-checkout-cards" class="ncf__button ncf__button--debug ncf__button--inverse" onclick="window.open('https://www.checkout.com/docs/testing/test-card-numbers#Credit_cards', '_blank');" title="Checkout test cards documentation">Doc:Checkout</button>
|
|
23
24
|
`;
|
|
24
25
|
const linksString = Object.keys(links).map(
|
|
25
26
|
(link) =>
|
|
@@ -27,9 +28,9 @@ export function Debug ({ isTest = false, showHelpers = false, links = {} }) {
|
|
|
27
28
|
);
|
|
28
29
|
const helpers = `
|
|
29
30
|
<span class="ncf__debug-helpers">
|
|
30
|
-
<button class="ncf__button ncf__button--inverse" onclick="logout();" title="Logout and refresh">Logout</button>
|
|
31
|
-
<button class="ncf__button ncf__button--inverse" onclick="fillForm();" title="Fill form with debug data">Fill</button>
|
|
32
|
-
<button class="ncf__button ncf__button--inverse" onclick="fillForm(); submitForm();" title="Fill form with debug data and submit">Fill & Submit</button>
|
|
31
|
+
<button class="ncf__button ncf__button--debug ncf__button--inverse" onclick="logout();" title="Logout and refresh">Logout</button>
|
|
32
|
+
<button class="ncf__button ncf__button--debug ncf__button--inverse" onclick="fillForm();" title="Fill form with debug data">Fill</button>
|
|
33
|
+
<button class="ncf__button ncf__button--debug ncf__button--inverse" onclick="fillForm(); submitForm();" title="Fill form with debug data and submit">Fill & Submit</button>
|
|
33
34
|
${isTest ? testCards : ''}
|
|
34
35
|
${links.length ? linksString : ''}
|
|
35
36
|
</span>
|
|
@@ -55,7 +56,7 @@ export function Debug ({ isTest = false, showHelpers = false, links = {} }) {
|
|
|
55
56
|
GBR: 'EC4M9BT',
|
|
56
57
|
USA: '10028',
|
|
57
58
|
CAN: 'K0E 9Z9'
|
|
58
|
-
}
|
|
59
|
+
};
|
|
59
60
|
|
|
60
61
|
var debugData = {
|
|
61
62
|
billingCity: 'London',
|
|
@@ -79,9 +80,12 @@ export function Debug ({ isTest = false, showHelpers = false, links = {} }) {
|
|
|
79
80
|
postCode: postcodeByCountry[COUNTRY_CODE],
|
|
80
81
|
primaryTelephone: '0987654321',
|
|
81
82
|
responsibility: 'ADL',
|
|
82
|
-
|
|
83
|
+
ukVisaWorldpay: '4111111111111111',
|
|
83
84
|
usAmex: '378282246310005',
|
|
84
|
-
|
|
85
|
+
usVisaWorldpay: '4112344112344113',
|
|
86
|
+
checkoutVisa: '4242424242424242',
|
|
87
|
+
checkout3dsChallenge: 'Checkout1!',
|
|
88
|
+
chaseVisa: '4011361100000010',
|
|
85
89
|
};
|
|
86
90
|
|
|
87
91
|
function logout () {
|
|
@@ -157,6 +161,9 @@ export function Debug ({ isTest = false, showHelpers = false, links = {} }) {
|
|
|
157
161
|
.ncf__debug-button--production {
|
|
158
162
|
background-color: #990000;
|
|
159
163
|
}
|
|
164
|
+
.ncf__button--debug {
|
|
165
|
+
padding: 0px 5px;
|
|
166
|
+
}
|
|
160
167
|
`,
|
|
161
168
|
};
|
|
162
169
|
|
package/components/index.jsx
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export { AcceptTerms } from './accept-terms';
|
|
2
2
|
export { AppBanner } from './app-banner';
|
|
3
|
-
export { B2cPartnershipPaymentTerm } from './b2c-partnership-payment-term';
|
|
4
3
|
export { BillingCity } from './billing-city';
|
|
5
4
|
export { BillingCountry } from './billing-country';
|
|
6
5
|
export { BillingPostcode } from './billing-postcode';
|
|
@@ -54,3 +53,4 @@ export { EducationJobTitle } from './education-job-title';
|
|
|
54
53
|
export { GraduationDate } from './graduation-date';
|
|
55
54
|
export { LiteSubConfirmation } from './lite-sub-confirmation';
|
|
56
55
|
export { GoogleSignIn } from './google-sign-in';
|
|
56
|
+
export { TextInput } from './text-input';
|
|
@@ -26,11 +26,11 @@ export function PaymentTerm ({
|
|
|
26
26
|
* @param {string} period PxY (yearly) or PxM (montly) where x is the amount of years/months
|
|
27
27
|
* @returns {string}
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
const getMontlyPriceFromPeriod = (amount, currency, period) => {
|
|
30
30
|
const periodObj = new Period(period);
|
|
31
31
|
const monthlyPrice = periodObj.calculatePrice('P1M', amount);
|
|
32
32
|
return new Monthly({ value: monthlyPrice, currency }).getAmount('monthly');
|
|
33
|
-
}
|
|
33
|
+
};
|
|
34
34
|
|
|
35
35
|
/**
|
|
36
36
|
* returns period converted to time if found
|
|
@@ -192,6 +192,15 @@ export function PaymentTerm ({
|
|
|
192
192
|
);
|
|
193
193
|
};
|
|
194
194
|
|
|
195
|
+
const createB2cDiscountCopy = () => {
|
|
196
|
+
return (
|
|
197
|
+
option.name === 'annual' && option.b2cPartnership && option.b2cDiscountCopy && (
|
|
198
|
+
<span className="ncf__payment-term__discount">
|
|
199
|
+
{option.b2cDiscountCopy}
|
|
200
|
+
</span>
|
|
201
|
+
)
|
|
202
|
+
);
|
|
203
|
+
};
|
|
195
204
|
const createDescription = () => {
|
|
196
205
|
return option.isTrial ? (
|
|
197
206
|
<div className="ncf__payment-term__description">
|
|
@@ -285,6 +294,7 @@ export function PaymentTerm ({
|
|
|
285
294
|
className="o-forms-input__label ncf__payment-term__label"
|
|
286
295
|
>
|
|
287
296
|
{createDiscount()}
|
|
297
|
+
{createB2cDiscountCopy()}
|
|
288
298
|
|
|
289
299
|
<span
|
|
290
300
|
className={classNames([
|
|
@@ -365,6 +375,8 @@ PaymentTerm.propTypes = {
|
|
|
365
375
|
isEpaper: PropTypes.bool,
|
|
366
376
|
options: PropTypes.arrayOf(
|
|
367
377
|
PropTypes.shape({
|
|
378
|
+
b2cDiscountCopy: PropTypes.string,
|
|
379
|
+
isB2cPartnership: PropTypes.bool,
|
|
368
380
|
discount: PropTypes.string,
|
|
369
381
|
isTrial: PropTypes.bool,
|
|
370
382
|
name: PropTypes.string.isRequired,
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import classNames from 'classnames';
|
|
4
|
+
|
|
5
|
+
export function TextInput ({
|
|
6
|
+
dataTrackable,
|
|
7
|
+
errorText = 'Please enter a value',
|
|
8
|
+
fieldId,
|
|
9
|
+
hasError = false,
|
|
10
|
+
inputId,
|
|
11
|
+
inputName,
|
|
12
|
+
isDisabled = false,
|
|
13
|
+
isRequired = false,
|
|
14
|
+
label = '',
|
|
15
|
+
placeHolder = '',
|
|
16
|
+
value = '',
|
|
17
|
+
description,
|
|
18
|
+
}) {
|
|
19
|
+
// Use inputId if inputName is not explicitly passed.
|
|
20
|
+
inputName = inputName || inputId;
|
|
21
|
+
|
|
22
|
+
const inputWrapperClassNames = classNames([
|
|
23
|
+
'o-forms-input',
|
|
24
|
+
'o-forms-input--text',
|
|
25
|
+
{ 'o-forms-input--invalid': hasError },
|
|
26
|
+
{ 'o-forms-field--optional': !isRequired },
|
|
27
|
+
]);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<label
|
|
31
|
+
id={fieldId}
|
|
32
|
+
className="o-forms-field ncf__validation-error"
|
|
33
|
+
data-validate="required"
|
|
34
|
+
htmlFor={inputId}
|
|
35
|
+
>
|
|
36
|
+
<span className="o-forms-title">
|
|
37
|
+
<span className="o-forms-title__main">{label}</span>
|
|
38
|
+
{description ? (
|
|
39
|
+
<span className="o-forms-title__prompt">{description}</span>
|
|
40
|
+
) : null}
|
|
41
|
+
</span>
|
|
42
|
+
<span className={inputWrapperClassNames}>
|
|
43
|
+
<input
|
|
44
|
+
type="text"
|
|
45
|
+
id={inputId}
|
|
46
|
+
name={inputName}
|
|
47
|
+
placeholder={placeHolder}
|
|
48
|
+
data-trackable={dataTrackable}
|
|
49
|
+
aria-required={isRequired}
|
|
50
|
+
required={isRequired}
|
|
51
|
+
disabled={isDisabled}
|
|
52
|
+
defaultValue={value}
|
|
53
|
+
/>
|
|
54
|
+
<span className="o-forms-input__error">{errorText}</span>
|
|
55
|
+
</span>
|
|
56
|
+
</label>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
TextInput.propTypes = {
|
|
61
|
+
dataTrackable: PropTypes.string,
|
|
62
|
+
errorText: PropTypes.string,
|
|
63
|
+
fieldId: PropTypes.string,
|
|
64
|
+
hasError: PropTypes.bool,
|
|
65
|
+
inputId: PropTypes.string,
|
|
66
|
+
inputName: PropTypes.string,
|
|
67
|
+
isDisabled: PropTypes.bool,
|
|
68
|
+
isRequired: PropTypes.bool,
|
|
69
|
+
label: PropTypes.string,
|
|
70
|
+
placeHolder: PropTypes.string,
|
|
71
|
+
value: PropTypes.string,
|
|
72
|
+
description: PropTypes.string,
|
|
73
|
+
};
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { TextInput } from './index';
|
|
2
|
+
|
|
3
|
+
import Enzyme, { mount } from 'enzyme';
|
|
4
|
+
import Adapter from 'enzyme-adapter-react-16';
|
|
5
|
+
Enzyme.configure({ adapter: new Adapter() });
|
|
6
|
+
|
|
7
|
+
describe('Text Input', () => {
|
|
8
|
+
it('renders with default props', () => {
|
|
9
|
+
const props = {};
|
|
10
|
+
|
|
11
|
+
const component = mount(TextInput(props));
|
|
12
|
+
const element = component.find('input');
|
|
13
|
+
|
|
14
|
+
expect(element.exists()).toBe(true);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('renders a field with custom field id', () => {
|
|
18
|
+
const props = { fieldId: 'customFieldId' };
|
|
19
|
+
|
|
20
|
+
const component = mount(TextInput(props));
|
|
21
|
+
const element = component.find('#customFieldId');
|
|
22
|
+
|
|
23
|
+
expect(element.exists()).toBe(true);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('renders with an error', () => {
|
|
27
|
+
const props = { hasError: true, errorText: 'Invalid value' };
|
|
28
|
+
|
|
29
|
+
const component = mount(TextInput(props));
|
|
30
|
+
const element = component.find('.o-forms-input--invalid');
|
|
31
|
+
const errorMsg = component.find('.o-forms-input__error');
|
|
32
|
+
|
|
33
|
+
expect(element.exists()).toBe(true);
|
|
34
|
+
expect(errorMsg.text()).toEqual('Invalid value');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('renders a field with custom input id', () => {
|
|
38
|
+
const props = { inputId: 'customInputId' };
|
|
39
|
+
|
|
40
|
+
const component = mount(TextInput(props));
|
|
41
|
+
const element = component.find('input#customInputId');
|
|
42
|
+
|
|
43
|
+
expect(element.exists()).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('renders a field with custom input name', () => {
|
|
47
|
+
const CUSTOM_INPUT_NAME = 'customInputName';
|
|
48
|
+
const props = { inputName: CUSTOM_INPUT_NAME };
|
|
49
|
+
|
|
50
|
+
const component = mount(TextInput(props));
|
|
51
|
+
const element = component.find('input');
|
|
52
|
+
|
|
53
|
+
expect(element.prop('name')).toBe(CUSTOM_INPUT_NAME);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it('renders with a custom value', () => {
|
|
57
|
+
const props = { value: 'foobar' };
|
|
58
|
+
|
|
59
|
+
const component = mount(TextInput(props));
|
|
60
|
+
const element = component.find('input');
|
|
61
|
+
|
|
62
|
+
expect(element.prop('defaultValue')).toEqual('foobar');
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('renders with disabled input', () => {
|
|
66
|
+
const props = { isDisabled: true };
|
|
67
|
+
|
|
68
|
+
const component = mount(TextInput(props));
|
|
69
|
+
const element = component.find('input[disabled=true]');
|
|
70
|
+
|
|
71
|
+
expect(element.exists()).toBe(true);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('renders with default label wording', () => {
|
|
75
|
+
const props = {};
|
|
76
|
+
|
|
77
|
+
const component = mount(TextInput(props));
|
|
78
|
+
const label = component.find('.o-forms-title__main');
|
|
79
|
+
|
|
80
|
+
expect(label.text()).toEqual('');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it('renders with custom label wording', () => {
|
|
84
|
+
const props = { label: 'Code' };
|
|
85
|
+
|
|
86
|
+
const component = mount(TextInput(props));
|
|
87
|
+
const label = component.find('.o-forms-title__main');
|
|
88
|
+
|
|
89
|
+
expect(label.text()).toEqual('Code');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('renders with custom description wording', () => {
|
|
93
|
+
const props = { description: 'Description text' };
|
|
94
|
+
|
|
95
|
+
const component = mount(TextInput(props));
|
|
96
|
+
const description = component.find('.o-forms-title__prompt');
|
|
97
|
+
|
|
98
|
+
expect(description.text()).toEqual('Description text');
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('renders as required field', () => {
|
|
102
|
+
const props = { isRequired: true };
|
|
103
|
+
|
|
104
|
+
const component = mount(TextInput(props));
|
|
105
|
+
const element = component.find('input[required=true]');
|
|
106
|
+
|
|
107
|
+
expect(element.exists()).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('renders as optional field', () => {
|
|
111
|
+
const props = { isRequired: false };
|
|
112
|
+
|
|
113
|
+
const component = mount(TextInput(props));
|
|
114
|
+
const element = component.find('input[required=true]');
|
|
115
|
+
|
|
116
|
+
expect(element.exists()).toBe(false);
|
|
117
|
+
});
|
|
118
|
+
});
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TextInput } from './text-input';
|
|
3
|
+
|
|
4
|
+
export default {
|
|
5
|
+
title: 'Text Input',
|
|
6
|
+
component: TextInput,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export const Basic = (args) => <TextInput {...args} />;
|
|
10
|
+
Basic.args = {
|
|
11
|
+
label: 'Text Input',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export const VerificationCode = (args) => <TextInput {...args} />;
|
|
15
|
+
VerificationCode.args = {
|
|
16
|
+
dataTrackable: 'verification-code',
|
|
17
|
+
errorText: 'This verification code is incorrect, please try again',
|
|
18
|
+
fieldId: 'verificationCodeField',
|
|
19
|
+
inputId: 'verificationCode',
|
|
20
|
+
isRequired: true,
|
|
21
|
+
placeHolder: 'Enter code',
|
|
22
|
+
description:
|
|
23
|
+
'An email with a link and verification code has been sent to your email. Enter the code below or follow the link in the email to continue.',
|
|
24
|
+
hasError: true,
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const Comments = (args) => <TextInput {...args} />;
|
|
28
|
+
Comments.args = {
|
|
29
|
+
label: 'Comments',
|
|
30
|
+
placeHolder: 'Please enter your comments',
|
|
31
|
+
};
|
|
@@ -32,7 +32,7 @@ function B2CPartnershipConfirmation(_ref) {
|
|
|
32
32
|
className: "ncf__paragraph"
|
|
33
33
|
}, /*#__PURE__*/_react["default"].createElement("h1", {
|
|
34
34
|
className: "ncf__header ncf__header--confirmation"
|
|
35
|
-
}, 'Welcome to your
|
|
35
|
+
}, 'Welcome to your 30 days\' Premium access'))), /*#__PURE__*/_react["default"].createElement("p", {
|
|
36
36
|
className: "ncf__paragraph"
|
|
37
37
|
}, "Please check your email to confirm your account and set your password."), /*#__PURE__*/_react["default"].createElement("p", {
|
|
38
38
|
className: "ncf__paragraph"
|
package/dist/confirmation.js
CHANGED
|
@@ -24,6 +24,8 @@ function Confirmation(_ref) {
|
|
|
24
24
|
isTrial = _ref$isTrial === void 0 ? false : _ref$isTrial,
|
|
25
25
|
_ref$isB2cPartnership = _ref.isB2cPartnership,
|
|
26
26
|
isB2cPartnership = _ref$isB2cPartnership === void 0 ? false : _ref$isB2cPartnership,
|
|
27
|
+
_ref$b2cPartnershipCo = _ref.b2cPartnershipCopy,
|
|
28
|
+
b2cPartnershipCopy = _ref$b2cPartnershipCo === void 0 ? [] : _ref$b2cPartnershipCo,
|
|
27
29
|
_ref$offer = _ref.offer,
|
|
28
30
|
offer = _ref$offer === void 0 ? '' : _ref$offer,
|
|
29
31
|
_ref$email = _ref.email,
|
|
@@ -77,9 +79,13 @@ function Confirmation(_ref) {
|
|
|
77
79
|
className: "ncf__paragraph--reduced-padding ncf__paragraph--subscription-confirmation"
|
|
78
80
|
}, "You are now subscribed to:"), /*#__PURE__*/_react["default"].createElement("h1", {
|
|
79
81
|
className: "ncf__header ncf__header--confirmation"
|
|
80
|
-
}, offer)), nextActionTop, /*#__PURE__*/_react["default"].createElement("p", {
|
|
82
|
+
}, offer)), nextActionTop, !isB2cPartnership && /*#__PURE__*/_react["default"].createElement("p", {
|
|
81
83
|
className: "ncf__paragraph"
|
|
82
|
-
}, "We\u2019ve sent confirmation to ", email, ". Make sure you check your spam folder if you don\u2019t receive it."), isB2cPartnership
|
|
84
|
+
}, "We\u2019ve sent confirmation to ", email, ". Make sure you check your spam folder if you don\u2019t receive it."), isB2cPartnership && b2cPartnershipCopy.length > 0 ? /*#__PURE__*/_react["default"].createElement("p", {
|
|
85
|
+
className: "ncf__paragraph"
|
|
86
|
+
}, b2cPartnershipCopy[0], /*#__PURE__*/_react["default"].createElement("span", {
|
|
87
|
+
className: "ncf__legend"
|
|
88
|
+
}, " ".concat(email, ". ")), b2cPartnershipCopy[1]) : '', /*#__PURE__*/_react["default"].createElement("p", {
|
|
83
89
|
className: "ncf__paragraph"
|
|
84
90
|
}, "Here\u2019s a summary of your ", offer, " subscription:"), detailElements, directDebitMandateUrlElement, /*#__PURE__*/_react["default"].createElement("div", {
|
|
85
91
|
className: "ncf__headed-paragraph"
|
|
@@ -109,6 +115,7 @@ function Confirmation(_ref) {
|
|
|
109
115
|
Confirmation.propTypes = {
|
|
110
116
|
isTrial: _propTypes["default"].bool,
|
|
111
117
|
isB2cPartnership: _propTypes["default"].bool,
|
|
118
|
+
b2cPartnershipCopy: _propTypes["default"].array,
|
|
112
119
|
offer: _propTypes["default"].string.isRequired,
|
|
113
120
|
email: _propTypes["default"].string,
|
|
114
121
|
details: _propTypes["default"].arrayOf(_propTypes["default"].shape({
|