@financial-times/n-conversion-forms 32.10.0 → 32.12.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 (37) hide show
  1. package/.circleci/config.yml +1 -3
  2. package/.toolkitstate/ci.json +2 -2
  3. package/components/accept-terms-subscription.spec.js +3 -3
  4. package/components/company-name.spec.js +2 -4
  5. package/components/delivery-security-instructions.spec.js +6 -6
  6. package/components/graduation-date.spec.js +2 -2
  7. package/components/industry.spec.js +4 -4
  8. package/components/job-title.spec.js +2 -2
  9. package/components/payment-term.jsx +15 -2
  10. package/components/payment-term.spec.js +16 -3
  11. package/components/payment-term.stories.js +35 -0
  12. package/components/personal-title.spec.js +4 -6
  13. package/components/phone.spec.js +2 -2
  14. package/components/position.spec.js +2 -2
  15. package/components/responsibility.spec.js +2 -2
  16. package/components/text-input.spec.js +5 -5
  17. package/dist/payment-term.jsx +19 -4
  18. package/helpers/ncf-countries.spec.js +2 -2
  19. package/package.json +35 -37
  20. package/test-jest/helpers/expect-to-render-correctly.js +1 -0
  21. package/utils/apple-pay.spec.js +1 -1
  22. package/utils/billing-postcode.spec.js +8 -8
  23. package/utils/company-name.spec.js +1 -1
  24. package/utils/delivery-address-type.spec.js +1 -1
  25. package/utils/delivery-option.spec.js +2 -2
  26. package/utils/delivery-postcode.spec.js +7 -7
  27. package/utils/delivery-start-date.spec.js +2 -4
  28. package/utils/form-element.spec.js +1 -1
  29. package/utils/loader.spec.js +3 -3
  30. package/utils/password.spec.js +2 -2
  31. package/utils/payment-term.spec.js +3 -3
  32. package/utils/payment-type.spec.js +1 -1
  33. package/utils/postcode.spec.js +7 -13
  34. package/utils/salesforce.spec.js +2 -2
  35. package/utils/submit.spec.js +1 -1
  36. package/utils/validation.spec.js +2 -2
  37. package/utils/zuora.spec.js +2 -0
@@ -1,7 +1,7 @@
1
1
  # CONFIG GENERATED BY DOTCOM-TOOL-KIT, DO NOT EDIT BY HAND
2
2
  version: 2.1
3
3
  orbs:
4
- tool-kit: financial-times/dotcom-tool-kit@4
4
+ tool-kit: financial-times/dotcom-tool-kit@5
5
5
  executors:
6
6
  node:
7
7
  docker:
@@ -31,8 +31,6 @@ workflows:
31
31
  filters:
32
32
  branches:
33
33
  only: /(^renovate-.*|^nori/.*)/
34
- tags:
35
- only: /^v\d+\.\d+\.\d+(-.+)?/
36
34
  - tool-kit/setup:
37
35
  name: tool-kit/setup-<< matrix.executor >>
38
36
  requires:
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "branch": "",
3
3
  "repo": "n-conversion-forms",
4
- "version": "b79816d6c6908ec0ab098d2724e89a89f204cba1",
5
- "tag": "v32.10.0"
4
+ "version": "c7bf91fc151991e214cb6ee5d430825c6f9adefa",
5
+ "tag": "v32.12.0"
6
6
  }
@@ -81,13 +81,13 @@ describe('AcceptTermsSubscription', () => {
81
81
  const transitionTerms2 = component.find('.terms-transition').at(1);
82
82
  const transitionTerms3 = component.find('.terms-transition').at(2);
83
83
 
84
- expect(transitionTerms1.text()).toEqual(
84
+ expect(transitionTerms1.text()).toBe(
85
85
  'I give consent for the chosen payment method to be charged automatically.'
86
86
  );
87
- expect(transitionTerms2.text()).toEqual(
87
+ expect(transitionTerms2.text()).toBe(
88
88
  'By placing your order subject to the Terms & Conditions (save for section 2) referred to below, you are waiving your statutory right to cancel our contract within 14 days of payment. Your payment is a one-time payment collected at the time of checkout, and unsubscribing or cancelling at any point (whether before or after the 14-day period) will not entitle you to a refund.'
89
89
  );
90
- expect(transitionTerms3.text()).toEqual(
90
+ expect(transitionTerms3.text()).toBe(
91
91
  'Please see here for the complete Terms & Conditions.'
92
92
  );
93
93
  });
@@ -69,9 +69,7 @@ describe('CompanyName', () => {
69
69
 
70
70
  const component = mount(CompanyName(props));
71
71
 
72
- expect(component.find('.o-forms-title__main').text()).toEqual(
73
- 'Company name'
74
- );
72
+ expect(component.find('.o-forms-title__main').text()).toBe('Company name');
75
73
  });
76
74
 
77
75
  it('renders with custom label wording', () => {
@@ -79,7 +77,7 @@ describe('CompanyName', () => {
79
77
 
80
78
  const component = mount(CompanyName(props));
81
79
 
82
- expect(component.find('.o-forms-title__main').text()).toEqual(
80
+ expect(component.find('.o-forms-title__main').text()).toBe(
83
81
  'Organisation name'
84
82
  );
85
83
  });
@@ -10,7 +10,7 @@ describe('DeliverySecurityInstructions', () => {
10
10
  wrapper = shallow(<DeliverySecurityInstructions />);
11
11
  });
12
12
 
13
- test('contains textAreaProps id set to default: deliverySecurityInstructionsField ', () => {
13
+ test('contains textAreaProps id set to default: deliverySecurityInstructionsField', () => {
14
14
  expect(wrapper.prop('id')).toBe('deliverySecurityInstructionsField');
15
15
  });
16
16
 
@@ -55,11 +55,11 @@ describe('DeliverySecurityInstructions', () => {
55
55
  });
56
56
 
57
57
  it('does not set maxLength when no value is given', () => {
58
- expect(textAreaProps.maxLength).toBeUndefined;
58
+ expect(textAreaProps.maxLength).toBeUndefined();
59
59
  });
60
60
 
61
61
  it('does not set rows when no value is given', () => {
62
- expect(textAreaProps.rows).toBeUndefined;
62
+ expect(textAreaProps.rows).toBeUndefined();
63
63
  });
64
64
 
65
65
  it('sets data-trackable to field-deliverySecurityInstructions', () => {
@@ -75,11 +75,11 @@ describe('DeliverySecurityInstructions', () => {
75
75
  });
76
76
 
77
77
  it('sets disabled to false', () => {
78
- expect(textAreaProps.disabled).toBeFalse;
78
+ expect(textAreaProps.disabled).toBe(false);
79
79
  });
80
80
 
81
81
  it('does not set value when no value is given', () => {
82
- expect(textAreaProps.defaultValue).toBeUndefined;
82
+ expect(textAreaProps.defaultValue).toBe('');
83
83
  });
84
84
  });
85
85
 
@@ -117,7 +117,7 @@ describe('DeliverySecurityInstructions', () => {
117
117
  });
118
118
 
119
119
  it('sets disabled to true', () => {
120
- expect(textAreaProps.disabled).toBeTrue;
120
+ expect(textAreaProps.disabled).toBe(true);
121
121
  });
122
122
 
123
123
  it('sets value', () => {
@@ -86,13 +86,13 @@ describe('GraduationDate', () => {
86
86
  const wrapper = shallow(<GraduationDate value="2020-08-28" />);
87
87
 
88
88
  it('sets the default month', () => {
89
- expect(wrapper.find('#graduationDateMonth').prop('defaultValue')).toEqual(
89
+ expect(wrapper.find('#graduationDateMonth').prop('defaultValue')).toBe(
90
90
  '08'
91
91
  );
92
92
  });
93
93
 
94
94
  it('sets the default year', () => {
95
- expect(wrapper.find('#graduationDateYear').prop('defaultValue')).toEqual(
95
+ expect(wrapper.find('#graduationDateYear').prop('defaultValue')).toBe(
96
96
  '2020'
97
97
  );
98
98
  });
@@ -71,7 +71,7 @@ describe('Industry', () => {
71
71
 
72
72
  const component = mount(Industry(props));
73
73
 
74
- expect(component.find('.o-forms-title__main').text()).toEqual(
74
+ expect(component.find('.o-forms-title__main').text()).toBe(
75
75
  'In which industry do you work?'
76
76
  );
77
77
  });
@@ -81,7 +81,7 @@ describe('Industry', () => {
81
81
 
82
82
  const component = mount(Industry(props));
83
83
 
84
- expect(component.find('.o-forms-title__main').text()).toEqual('Industry');
84
+ expect(component.find('.o-forms-title__main').text()).toBe('Industry');
85
85
  });
86
86
 
87
87
  it('renders with optional title class, when not required', () => {
@@ -89,7 +89,7 @@ describe('Industry', () => {
89
89
  const component = mount(Industry(props));
90
90
 
91
91
  expect(
92
- component.find('.o-forms-title.o-forms-field--optional').length
93
- ).toEqual(1);
92
+ component.find('.o-forms-title.o-forms-field--optional')
93
+ ).toHaveLength(1);
94
94
  });
95
95
  });
@@ -64,7 +64,7 @@ describe('JobTitle', () => {
64
64
  const component = mount(JobTitle(props));
65
65
 
66
66
  expect(
67
- component.find('.o-forms-title.o-forms-field--optional').length
68
- ).toEqual(1);
67
+ component.find('.o-forms-title.o-forms-field--optional')
68
+ ).toHaveLength(1);
69
69
  });
70
70
  });
@@ -17,6 +17,8 @@ export function PaymentTerm({
17
17
  billingCountry = '',
18
18
  is7DayPassExperiment = false,
19
19
  isTermedSubscriptionTermType = false,
20
+ isTrialOfferAsNonTrialOverride = false,
21
+ labelOverride = '', // this is a temporary hack for the February 2024 campaign
20
22
  }) {
21
23
  /**
22
24
  * Compute monthly price for given term name
@@ -25,7 +27,7 @@ export function PaymentTerm({
25
27
  * @param {string} period (expressed in IS0 8601 duration format): e.g. PxY (yearly) or PxM (montly) where x is the amount of years/months
26
28
  * @returns {string}
27
29
  */
28
- const getMontlyPriceFromPeriod = (amount, currency, period) => {
30
+ const getMonthlyPriceFromPeriod = (amount, currency, period) => {
29
31
  const periodObj = new Period(period);
30
32
  const monthlyPrice = periodObj.calculatePrice('P1M', amount);
31
33
  return new Monthly({ value: monthlyPrice, currency }).getAmount('monthly');
@@ -268,7 +270,7 @@ export function PaymentTerm({
268
270
  {nameMap['custom'].monthlyPrice(
269
271
  option.monthlyPrice && option.monthlyPrice !== '0'
270
272
  ? Number(option.monthlyPrice)
271
- : getMontlyPriceFromPeriod(
273
+ : getMonthlyPriceFromPeriod(
272
274
  option.amount,
273
275
  option.currency,
274
276
  option.value
@@ -298,6 +300,16 @@ export function PaymentTerm({
298
300
  const showTrialCopyInTitle =
299
301
  option.isTrial && !isPrintOrBundle && !isEpaper;
300
302
 
303
+ // https://financialtimes.atlassian.net/browse/ACQ-2592
304
+ // We need to have one specific trial offer to have terms displayed as non-trial.
305
+ // The offer is a trial offer and should use trial mechanics but should show as non-trial.
306
+ // There is nothing in the offer payload to identify when this should happen, we need to rely on the offer id.
307
+ // This is a TEMPORARY hack and will be removed once the campaign is over.
308
+ // A ticket as been raised already to deal with the clean up: https://financialtimes.atlassian.net/browse/ACQ-2593.
309
+ if (isTrialOfferAsNonTrialOverride && labelOverride) {
310
+ return labelOverride;
311
+ }
312
+
301
313
  const defaultTitle = (() => {
302
314
  if (is7DayPassExperiment) {
303
315
  return '';
@@ -461,4 +473,5 @@ PaymentTerm.propTypes = {
461
473
  largePrice: PropTypes.bool,
462
474
  optionsInARow: PropTypes.bool,
463
475
  billingCountry: PropTypes.string,
476
+ isTrialOfferAsNonTrialOverride: PropTypes.bool,
464
477
  };
@@ -261,7 +261,7 @@ describe('PaymentTerm', () => {
261
261
  );
262
262
  });
263
263
  });
264
- describe('getDisplayName', () => {
264
+ describe('getDisplayName trial', () => {
265
265
  const trialOptions = {
266
266
  ...baseOptions,
267
267
  isTrial: true,
@@ -273,6 +273,19 @@ describe('PaymentTerm', () => {
273
273
  /^Trial: Premium Digital - Monthly .*$/
274
274
  );
275
275
  });
276
+ it('handles trial to non-trial payment term display name', () => {
277
+ const options = [trialOptions];
278
+ const wrapper = shallow(
279
+ <PaymentTerm
280
+ options={options}
281
+ labelOverride={'some term label'}
282
+ isTrialOfferAsNonTrialOverride={true}
283
+ />
284
+ );
285
+ expect(wrapper.find('.ncf__payment-term__label').text()).toMatch(
286
+ /^some term label.*$/
287
+ );
288
+ });
276
289
  it('renders using displayName if available', () => {
277
290
  const options = [
278
291
  {
@@ -318,7 +331,7 @@ describe('PaymentTerm', () => {
318
331
  },
319
332
  ];
320
333
  const wrapper = shallow(<PaymentTerm options={options} />);
321
- expect(wrapper.find('input').prop('data-base-amount')).toEqual(100);
334
+ expect(wrapper.find('input').prop('data-base-amount')).toBe(100);
322
335
  });
323
336
 
324
337
  it('renders option.trialAmount as data-base-amount if isTrial is true', () => {
@@ -334,7 +347,7 @@ describe('PaymentTerm', () => {
334
347
  },
335
348
  ];
336
349
  const wrapper = shallow(<PaymentTerm options={options} />);
337
- expect(wrapper.find('input').prop('data-base-amount')).toEqual(1);
350
+ expect(wrapper.find('input').prop('data-base-amount')).toBe(1);
338
351
  });
339
352
  });
340
353
 
@@ -183,3 +183,38 @@ RenewOffers.args = {
183
183
  ],
184
184
  optionsInARow: true,
185
185
  };
186
+
187
+ // https://financialtimes.atlassian.net/browse/ACQ-2592
188
+ // We need to have one specific trial offer to have terms displayed as non-trial.
189
+ // The offer is a trial offer and should use trial mechanics but should show as non-trial.
190
+ // There is nothing in the offer payload to identify when this should happen, we need to rely on the offer id.
191
+ // This is a TEMPORARY hack and will be removed once the campaign is over.
192
+ // A ticket as been raised already to deal with the clean up: https://financialtimes.atlassian.net/browse/ACQ-2593.
193
+ export const PaymentTermLabelOverride = (args) => (
194
+ <div className="ncf">
195
+ <Fieldset>
196
+ <PaymentTerm {...args} />
197
+ </Fieldset>
198
+ </div>
199
+ );
200
+
201
+ PaymentTermLabelOverride.args = {
202
+ isTrialOfferAsNonTrialOverride: true,
203
+ labelOverride: 'some fancy payment term',
204
+ options: [
205
+ {
206
+ name: '6 monthly',
207
+ isTrial: false,
208
+ discount: '',
209
+ selected: false,
210
+ price: '$229.00',
211
+ trialPrice: '$0.00',
212
+ trialDuration: '',
213
+ monthlyPrice: '0',
214
+ amount: '229.00',
215
+ trialAmount: null,
216
+ value: 'P6M',
217
+ currency: 'USD',
218
+ },
219
+ ],
220
+ };
@@ -71,7 +71,7 @@ describe('PersonalTitle', () => {
71
71
 
72
72
  const component = mount(PersonalTitle(props));
73
73
 
74
- expect(component.find('.o-forms-title__main').text()).toEqual('Title');
74
+ expect(component.find('.o-forms-title__main').text()).toBe('Title');
75
75
  });
76
76
 
77
77
  it('renders with custom label wording', () => {
@@ -79,9 +79,7 @@ describe('PersonalTitle', () => {
79
79
 
80
80
  const component = mount(PersonalTitle(props));
81
81
 
82
- expect(component.find('.o-forms-title__main').text()).toEqual(
83
- 'PersonalTitle'
84
- );
82
+ expect(component.find('.o-forms-title__main').text()).toBe('PersonalTitle');
85
83
  });
86
84
 
87
85
  it('renders with optional title class, when not required', () => {
@@ -89,7 +87,7 @@ describe('PersonalTitle', () => {
89
87
  const component = mount(PersonalTitle(props));
90
88
 
91
89
  expect(
92
- component.find('.o-forms-title.o-forms-field--optional').length
93
- ).toEqual(1);
90
+ component.find('.o-forms-title.o-forms-field--optional')
91
+ ).toHaveLength(1);
94
92
  });
95
93
  });
@@ -55,7 +55,7 @@ describe('Phone', () => {
55
55
  const component = mount(Phone(props));
56
56
 
57
57
  expect(
58
- component.find('.o-forms-title.o-forms-field--optional').length
59
- ).toEqual(1);
58
+ component.find('.o-forms-title.o-forms-field--optional')
59
+ ).toHaveLength(1);
60
60
  });
61
61
  });
@@ -65,7 +65,7 @@ describe('Position', () => {
65
65
  const component = mount(Position(props));
66
66
 
67
67
  expect(
68
- component.find('.o-forms-title.o-forms-field--optional').length
69
- ).toEqual(1);
68
+ component.find('.o-forms-title.o-forms-field--optional')
69
+ ).toHaveLength(1);
70
70
  });
71
71
  });
@@ -71,7 +71,7 @@ describe('Responsibility', () => {
71
71
  const component = mount(Responsibility(props));
72
72
 
73
73
  expect(
74
- component.find('.o-forms-title.o-forms-field--optional').length
75
- ).toEqual(1);
74
+ component.find('.o-forms-title.o-forms-field--optional')
75
+ ).toHaveLength(1);
76
76
  });
77
77
  });
@@ -31,7 +31,7 @@ describe('Text Input', () => {
31
31
  const errorMsg = component.find('.o-forms-input__error');
32
32
 
33
33
  expect(element.exists()).toBe(true);
34
- expect(errorMsg.text()).toEqual('Invalid value');
34
+ expect(errorMsg.text()).toBe('Invalid value');
35
35
  });
36
36
 
37
37
  it('renders a field with custom input id', () => {
@@ -59,7 +59,7 @@ describe('Text Input', () => {
59
59
  const component = mount(TextInput(props));
60
60
  const element = component.find('input');
61
61
 
62
- expect(element.prop('defaultValue')).toEqual('foobar');
62
+ expect(element.prop('defaultValue')).toBe('foobar');
63
63
  });
64
64
 
65
65
  it('renders with disabled input', () => {
@@ -77,7 +77,7 @@ describe('Text Input', () => {
77
77
  const component = mount(TextInput(props));
78
78
  const label = component.find('.o-forms-title__main');
79
79
 
80
- expect(label.text()).toEqual('');
80
+ expect(label.text()).toBe('');
81
81
  });
82
82
 
83
83
  it('renders with custom label wording', () => {
@@ -86,7 +86,7 @@ describe('Text Input', () => {
86
86
  const component = mount(TextInput(props));
87
87
  const label = component.find('.o-forms-title__main');
88
88
 
89
- expect(label.text()).toEqual('Code');
89
+ expect(label.text()).toBe('Code');
90
90
  });
91
91
 
92
92
  it('renders with custom description wording', () => {
@@ -95,7 +95,7 @@ describe('Text Input', () => {
95
95
  const component = mount(TextInput(props));
96
96
  const description = component.find('.o-forms-title__prompt');
97
97
 
98
- expect(description.text()).toEqual('Description text');
98
+ expect(description.text()).toBe('Description text');
99
99
  });
100
100
 
101
101
  it('renders as required field', () => {
@@ -37,7 +37,11 @@ function PaymentTerm(_ref) {
37
37
  _ref$is7DayPassExperi = _ref.is7DayPassExperiment,
38
38
  is7DayPassExperiment = _ref$is7DayPassExperi === void 0 ? false : _ref$is7DayPassExperi,
39
39
  _ref$isTermedSubscrip = _ref.isTermedSubscriptionTermType,
40
- isTermedSubscriptionTermType = _ref$isTermedSubscrip === void 0 ? false : _ref$isTermedSubscrip;
40
+ isTermedSubscriptionTermType = _ref$isTermedSubscrip === void 0 ? false : _ref$isTermedSubscrip,
41
+ _ref$isTrialOfferAsNo = _ref.isTrialOfferAsNonTrialOverride,
42
+ isTrialOfferAsNonTrialOverride = _ref$isTrialOfferAsNo === void 0 ? false : _ref$isTrialOfferAsNo,
43
+ _ref$labelOverride = _ref.labelOverride,
44
+ labelOverride = _ref$labelOverride === void 0 ? '' : _ref$labelOverride;
41
45
  /**
42
46
  * Compute monthly price for given term name
43
47
  * @param {number} amount price in number format
@@ -45,7 +49,7 @@ function PaymentTerm(_ref) {
45
49
  * @param {string} period (expressed in IS0 8601 duration format): e.g. PxY (yearly) or PxM (montly) where x is the amount of years/months
46
50
  * @returns {string}
47
51
  */
48
- var getMontlyPriceFromPeriod = function getMontlyPriceFromPeriod(amount, currency, period) {
52
+ var getMonthlyPriceFromPeriod = function getMonthlyPriceFromPeriod(amount, currency, period) {
49
53
  var periodObj = new _nPricing.Period(period);
50
54
  var monthlyPrice = periodObj.calculatePrice('P1M', amount);
51
55
  return new _nPricing.Monthly({
@@ -222,7 +226,7 @@ function PaymentTerm(_ref) {
222
226
  // for those containing period on option.value, render custom template, for the rest keep legacy render
223
227
  isValidPeriod(option.value) ? /*#__PURE__*/_react["default"].createElement("div", {
224
228
  className: "ncf__payment-term__description"
225
- }, nameMap['custom'].price(option.price), nameMap['custom'].monthlyPrice(option.monthlyPrice && option.monthlyPrice !== '0' ? Number(option.monthlyPrice) : getMontlyPriceFromPeriod(option.amount, option.currency, option.value)), nameMap['custom'].renewsText(getTimeFromPeriod(option.value))) : /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
229
+ }, nameMap['custom'].price(option.price), nameMap['custom'].monthlyPrice(option.monthlyPrice && option.monthlyPrice !== '0' ? Number(option.monthlyPrice) : getMonthlyPriceFromPeriod(option.amount, option.currency, option.value)), nameMap['custom'].renewsText(getTimeFromPeriod(option.value))) : /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement("span", {
226
230
  className: largePrice ? 'ncf__payment-term__large-price' : ''
227
231
  }, option.price), option.chargeOnText && /*#__PURE__*/_react["default"].createElement("p", {
228
232
  className: "ncf__payment-term__charge-on-text"
@@ -230,6 +234,16 @@ function PaymentTerm(_ref) {
230
234
  };
231
235
  var getTermDisplayName = function getTermDisplayName() {
232
236
  var showTrialCopyInTitle = option.isTrial && !isPrintOrBundle && !isEpaper;
237
+
238
+ // https://financialtimes.atlassian.net/browse/ACQ-2592
239
+ // We need to have one specific trial offer to have terms displayed as non-trial.
240
+ // The offer is a trial offer and should use trial mechanics but should show as non-trial.
241
+ // There is nothing in the offer payload to identify when this should happen, we need to rely on the offer id.
242
+ // This is a TEMPORARY hack and will be removed once the campaign is over.
243
+ // A ticket as been raised already to deal with the clean up: https://financialtimes.atlassian.net/browse/ACQ-2593.
244
+ if (isTrialOfferAsNonTrialOverride && labelOverride) {
245
+ return labelOverride;
246
+ }
233
247
  var defaultTitle = function () {
234
248
  if (is7DayPassExperiment) {
235
249
  return '';
@@ -330,5 +344,6 @@ PaymentTerm.propTypes = {
330
344
  showLegal: _propTypes["default"].bool,
331
345
  largePrice: _propTypes["default"].bool,
332
346
  optionsInARow: _propTypes["default"].bool,
333
- billingCountry: _propTypes["default"].string
347
+ billingCountry: _propTypes["default"].string,
348
+ isTrialOfferAsNonTrialOverride: _propTypes["default"].bool
334
349
  };
@@ -48,7 +48,7 @@ describe('ncf-countries', () => {
48
48
 
49
49
  expect(
50
50
  context.countries.find((country) => country.selected)
51
- ).not.toBeDefined();
51
+ ).toBeUndefined();
52
52
  });
53
53
 
54
54
  it('does not mark any countries selected if incorrect value passed', () => {
@@ -57,7 +57,7 @@ describe('ncf-countries', () => {
57
57
 
58
58
  expect(
59
59
  context.countries.find((country) => country.selected)
60
- ).not.toBeDefined();
60
+ ).toBeUndefined();
61
61
  });
62
62
 
63
63
  it('marks a country as selected if value matches code', () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "32.10.0",
3
+ "version": "32.12.0",
4
4
  "description": "Containing jsx components and styles for forms included on Accounts and Acqusition apps (next-signup, next-profile, next-retention, etc).",
5
5
  "main": "./dist/index.js",
6
6
  "scripts": {
@@ -25,61 +25,59 @@
25
25
  },
26
26
  "homepage": "https://github.com/Financial-Times/n-conversion-forms#readme",
27
27
  "dependencies": {
28
- "@babel/runtime": "^7.11.2",
29
- "@financial-times/n-pricing": "6.0.0",
30
- "classnames": "2.3.2",
28
+ "@babel/runtime": "^7.23.9",
29
+ "@financial-times/n-pricing": "7.1.0",
30
+ "classnames": "2.5.1",
31
31
  "fetchres": "1.7.2",
32
32
  "lodash.get": "4.4.2",
33
33
  "n-common-static-data": "github:Financial-Times/n-common-static-data#v2.4.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@babel/core": "^7.22.15",
37
- "@babel/plugin-transform-runtime": "^7.22.15",
38
- "@babel/preset-env": "^7.22.15",
39
- "@babel/preset-react": "^7.22.15",
40
- "@dotcom-tool-kit/babel": "^3.1.3",
41
- "@dotcom-tool-kit/component": "^4.0.4",
42
- "@dotcom-tool-kit/eslint": "^3.1.3",
43
- "@dotcom-tool-kit/frontend-app": "^3.1.9",
44
- "@dotcom-tool-kit/jest": "^3.2.0",
45
- "@dotcom-tool-kit/lint-staged-npm": "^3.1.6",
46
- "@dotcom-tool-kit/logger": "^3.1.1",
47
- "@dotcom-tool-kit/prettier": "^3.1.6",
48
- "@financial-times/eslint-config-next": "^6.0.0",
36
+ "@babel/core": "^7.23.9",
37
+ "@babel/plugin-transform-runtime": "^7.23.9",
38
+ "@babel/preset-env": "^7.23.9",
39
+ "@babel/preset-react": "^7.23.3",
40
+ "@dotcom-tool-kit/babel": "3.1.6",
41
+ "@dotcom-tool-kit/component": "4.1.2",
42
+ "@dotcom-tool-kit/eslint": "3.2.0",
43
+ "@dotcom-tool-kit/frontend-app": "3.2.3",
44
+ "@dotcom-tool-kit/jest": "3.4.0",
45
+ "@dotcom-tool-kit/lint-staged-npm": "3.2.0",
46
+ "@dotcom-tool-kit/logger": "3.4.0",
47
+ "@dotcom-tool-kit/prettier": "3.2.0",
48
+ "@financial-times/eslint-config-next": "7.1.0",
49
49
  "@financial-times/jest-browser-resolver": "^1.0.2",
50
- "@snyk/protect": "1.1193.0",
51
- "@storybook/addon-a11y": "^7.4.0",
52
- "@storybook/addon-essentials": "7.4.0",
53
- "@storybook/react": "^7.4.0",
54
- "@storybook/react-webpack5": "^7.4.0",
50
+ "@snyk/protect": "1.1278.0",
51
+ "@storybook/addon-a11y": "^7.6.13",
52
+ "@storybook/addon-essentials": "7.6.13",
53
+ "@storybook/react": "^7.6.13",
54
+ "@storybook/react-webpack5": "^7.6.13",
55
55
  "@sucrase/jest-plugin": "^3.0.0",
56
- "check-engines": "^1.5.0",
57
- "dotcom-tool-kit": "^3.2.1",
56
+ "check-engines": "^1.6.0",
57
+ "dotcom-tool-kit": "3.4.4",
58
58
  "enzyme": "^3.11.0",
59
59
  "enzyme-adapter-react-16": "^1.15.7",
60
- "eslint": "^8.28.0",
61
60
  "eslint-config-prettier": "^9.1.0",
62
- "eslint-plugin-jest": "^27.6.1",
63
- "eslint-plugin-prettier": "^5.1.2",
61
+ "eslint-plugin-jest": "^27.6.3",
62
+ "eslint-plugin-prettier": "^5.1.3",
64
63
  "eslint-plugin-react": "^7.33.2",
65
- "eslint-plugin-storybook": "^0.6.13",
64
+ "eslint-plugin-storybook": "^0.6.15",
66
65
  "fetch-mock": "^7.2.0",
67
- "html-webpack-plugin": "^5.5.3",
68
- "jest": "^29.6.4",
69
- "jest-environment-jsdom": "^29.6.4",
66
+ "html-webpack-plugin": "^5.6.0",
67
+ "jest": "^29.7.0",
68
+ "jest-environment-jsdom": "^29.7.0",
70
69
  "jest-serializer-html": "^7.1.0",
71
- "jsdom": "^22.1.0",
70
+ "jsdom": "^24.0.0",
72
71
  "jsdom-global": "^3.0.2",
73
- "lint-staged": "^13.0.4",
74
- "pa11y-ci": "2.4.2",
75
- "prop-types": "15.7.2",
72
+ "pa11y-ci": "3.1.0",
73
+ "prop-types": "15.8.1",
76
74
  "react": "16.14.0",
77
75
  "react-dom": "16.14.0",
78
76
  "react-is": "^16.13.1",
79
77
  "sass": "^1.55.0",
80
78
  "sass-loader": "^10.2.1",
81
- "storybook": "^7.4.0",
82
- "webpack": "^5.88.2",
79
+ "storybook": "^7.6.13",
80
+ "webpack": "^5.90.1",
83
81
  "webpack-cli": "^5.1.4"
84
82
  },
85
83
  "engines": {
@@ -7,6 +7,7 @@ export const expectToRenderCorrectly = {
7
7
  reactComponent(props)
8
8
  );
9
9
 
10
+ // eslint-disable-next-line jest/no-standalone-expect
10
11
  expect(ReactComponentRendered).toMatchSnapshot();
11
12
 
12
13
  // This point is reached when the above assertions were successful.
@@ -138,7 +138,7 @@ describe('Apple Pay', () => {
138
138
 
139
139
  it('returns merchant id from methods data', () => {
140
140
  const methods = [{ data: { merchantIdentifier: 'test' } }];
141
- expect(ApplePay.getMerchantId(methods)).toEqual('test');
141
+ expect(ApplePay.getMerchantId(methods)).toBe('test');
142
142
  });
143
143
  });
144
144
 
@@ -81,7 +81,7 @@ describe('BillingPostcode', () => {
81
81
  placeholder: 'Enter your postcode',
82
82
  });
83
83
  billingPostcode.changePostcodeReferenceForCountry = 'GBR';
84
- expect(querySelectorStub).toBeCalledWith('input');
84
+ expect(querySelectorStub).toHaveBeenCalledWith('input');
85
85
  });
86
86
 
87
87
  it('sets postcode placeholder to `Enter your postcode` by default', () => {
@@ -89,7 +89,7 @@ describe('BillingPostcode', () => {
89
89
  placeholder: 'Enter your zip code',
90
90
  });
91
91
  billingPostcode.changePostcodeReferenceForCountry = 'GBR';
92
- expect(billingPostcode.postcodeInput.placeholder).toEqual(
92
+ expect(billingPostcode.postcodeInput.placeholder).toBe(
93
93
  'Enter your postcode'
94
94
  );
95
95
  });
@@ -99,7 +99,7 @@ describe('BillingPostcode', () => {
99
99
  placeholder: 'Enter your postcode',
100
100
  });
101
101
  billingPostcode.changePostcodeReferenceForCountry = 'USA';
102
- expect(billingPostcode.postcodeInput.placeholder).toEqual(
102
+ expect(billingPostcode.postcodeInput.placeholder).toBe(
103
103
  'Enter your zip code'
104
104
  );
105
105
  });
@@ -109,7 +109,7 @@ describe('BillingPostcode', () => {
109
109
  placeholder: 'Enter your zip code',
110
110
  });
111
111
  billingPostcode.changePostcodeReferenceForCountry = 'CAN';
112
- expect(billingPostcode.postcodeInput.placeholder).toEqual(
112
+ expect(billingPostcode.postcodeInput.placeholder).toBe(
113
113
  'Enter your postal code'
114
114
  );
115
115
  });
@@ -117,20 +117,20 @@ describe('BillingPostcode', () => {
117
117
  });
118
118
 
119
119
  describe('getPostcodeReferenceByCountry', () => {
120
- it('returns post code by default ', () => {
121
- expect(BillingPostcode.getPostcodeReferenceByCountry('ZAR')).toEqual(
120
+ it('returns post code by default', () => {
121
+ expect(BillingPostcode.getPostcodeReferenceByCountry('ZAR')).toBe(
122
122
  'postcode'
123
123
  );
124
124
  });
125
125
 
126
126
  it('returns postal code when country is Canada', () => {
127
- expect(BillingPostcode.getPostcodeReferenceByCountry('CAN')).toEqual(
127
+ expect(BillingPostcode.getPostcodeReferenceByCountry('CAN')).toBe(
128
128
  'postal code'
129
129
  );
130
130
  });
131
131
 
132
132
  it('returns zip code when country is USA', () => {
133
- expect(BillingPostcode.getPostcodeReferenceByCountry('USA')).toEqual(
133
+ expect(BillingPostcode.getPostcodeReferenceByCountry('USA')).toBe(
134
134
  'zip code'
135
135
  );
136
136
  });
@@ -31,7 +31,7 @@ describe('Company Name - Util', () => {
31
31
  expect(document.querySelector('#companyNameField')).toBeDefined();
32
32
  expect(
33
33
  document.querySelector('.o-forms-field--optional #companyNameField')
34
- ).toBe(null);
34
+ ).toBeNull();
35
35
  });
36
36
  });
37
37
  });
@@ -39,7 +39,7 @@ describe('Delivery Address Type - Util', () => {
39
39
  const deliveryAdressTypeUtilInstance = new DeliveryAdressTypeUtil(
40
40
  document
41
41
  );
42
- expect(deliveryAdressTypeUtilInstance.getSelected()).toEqual('home');
42
+ expect(deliveryAdressTypeUtilInstance.getSelected()).toBe('home');
43
43
  });
44
44
 
45
45
  it('returns the option selected different than the default', () => {
@@ -48,12 +48,12 @@ describe('Delivery Option - Util', () => {
48
48
  deliveryoptionUtilInstance.showItem('PV');
49
49
  expect(document.querySelector('.ncf__hidden #HD')).toBeDefined();
50
50
  expect(document.querySelector('#PV')).toBeDefined();
51
- expect(document.querySelector('.ncf__hidden #PV')).toBe(null);
51
+ expect(document.querySelector('.ncf__hidden #PV')).toBeNull();
52
52
  deliveryoptionUtilInstance.showItem('HD');
53
53
  deliveryoptionUtilInstance.hideItem('PV');
54
54
  expect(document.querySelector('.ncf__hidden #PV')).toBeDefined();
55
55
  expect(document.querySelector('#HD')).toBeDefined();
56
- expect(document.querySelector('.ncf__hidden #HD')).toBe(null);
56
+ expect(document.querySelector('.ncf__hidden #HD')).toBeNull();
57
57
  });
58
58
  });
59
59
 
@@ -89,7 +89,7 @@ describe('DeliveryPostcode', () => {
89
89
  placeholder: 'Enter your zip code',
90
90
  });
91
91
  deliveryPostcode.changePostcodeReferenceForCountry = 'GBR';
92
- expect(deliveryPostcode.postcodeInput.placeholder).toEqual(
92
+ expect(deliveryPostcode.postcodeInput.placeholder).toBe(
93
93
  'Enter your postcode'
94
94
  );
95
95
  });
@@ -99,7 +99,7 @@ describe('DeliveryPostcode', () => {
99
99
  placeholder: 'Enter your postcode',
100
100
  });
101
101
  deliveryPostcode.changePostcodeReferenceForCountry = 'USA';
102
- expect(deliveryPostcode.postcodeInput.placeholder).toEqual(
102
+ expect(deliveryPostcode.postcodeInput.placeholder).toBe(
103
103
  'Enter your zip code'
104
104
  );
105
105
  });
@@ -109,7 +109,7 @@ describe('DeliveryPostcode', () => {
109
109
  placeholder: 'Enter your zip code',
110
110
  });
111
111
  deliveryPostcode.changePostcodeReferenceForCountry = 'CAN';
112
- expect(deliveryPostcode.postcodeInput.placeholder).toEqual(
112
+ expect(deliveryPostcode.postcodeInput.placeholder).toBe(
113
113
  'Enter your postal code'
114
114
  );
115
115
  });
@@ -117,20 +117,20 @@ describe('DeliveryPostcode', () => {
117
117
  });
118
118
 
119
119
  describe('getPostcodeReferenceByCountry', () => {
120
- it('returns post code by default ', () => {
121
- expect(DeliveryPostcode.getPostcodeReferenceByCountry('ZAR')).toEqual(
120
+ it('returns post code by default', () => {
121
+ expect(DeliveryPostcode.getPostcodeReferenceByCountry('ZAR')).toBe(
122
122
  'postcode'
123
123
  );
124
124
  });
125
125
 
126
126
  it('returns postal code when country is Canada', () => {
127
- expect(DeliveryPostcode.getPostcodeReferenceByCountry('CAN')).toEqual(
127
+ expect(DeliveryPostcode.getPostcodeReferenceByCountry('CAN')).toBe(
128
128
  'postal code'
129
129
  );
130
130
  });
131
131
 
132
132
  it('returns zip code when country is USA', () => {
133
- expect(DeliveryPostcode.getPostcodeReferenceByCountry('USA')).toEqual(
133
+ expect(DeliveryPostcode.getPostcodeReferenceByCountry('USA')).toBe(
134
134
  'zip code'
135
135
  );
136
136
  });
@@ -121,10 +121,8 @@ describe('DeliveryStartDate', () => {
121
121
 
122
122
  it('updates the page according to the response from the API call', async () => {
123
123
  await setup();
124
- expect(startDateFieldStub.value).toEqual('2019-04-13');
125
- expect(startDateTextStub.innerHTML).toEqual(
126
- 'Saturday 13th of April 2019'
127
- );
124
+ expect(startDateFieldStub.value).toBe('2019-04-13');
125
+ expect(startDateTextStub.innerHTML).toBe('Saturday 13th of April 2019');
128
126
  });
129
127
 
130
128
  it('clears errors and return true if the fetch call succeeds', async () => {
@@ -65,7 +65,7 @@ describe('FormElement', () => {
65
65
 
66
66
  describe('value', () => {
67
67
  it('returns the value', () => {
68
- expect(formElement.value()).toEqual('test');
68
+ expect(formElement.value()).toBe('test');
69
69
  });
70
70
  });
71
71
  });
@@ -54,7 +54,7 @@ describe('Loader', () => {
54
54
  it('cleares the content of the partial', () => {
55
55
  loader.setContent('<div>Baz</div>');
56
56
  loader.clearContent();
57
- expect(elementStub.innerHTML).toEqual('');
57
+ expect(elementStub.innerHTML).toBe('');
58
58
  });
59
59
  });
60
60
 
@@ -69,11 +69,11 @@ describe('Loader', () => {
69
69
  });
70
70
  it('sets the title of the partial', () => {
71
71
  loader.setContent({ title: 'Hooray!' });
72
- expect(elementStub.innerHTML).toEqual('Hooray!');
72
+ expect(elementStub.innerHTML).toBe('Hooray!');
73
73
  });
74
74
  it('sets the content of the partial', () => {
75
75
  loader.setContent({ content: '<div>Baz</div>' });
76
- expect(elementStub.innerHTML).toEqual('<div>Baz</div>');
76
+ expect(elementStub.innerHTML).toBe('<div>Baz</div>');
77
77
  });
78
78
  });
79
79
 
@@ -53,13 +53,13 @@ describe('Password', () => {
53
53
  it('sets the input type to text', () => {
54
54
  passwordElement.type = 'password';
55
55
  password.toggleMask(false);
56
- expect(passwordElement.type).toEqual('text');
56
+ expect(passwordElement.type).toBe('text');
57
57
  });
58
58
 
59
59
  it('sets the input type to password', () => {
60
60
  passwordElement.type = 'text';
61
61
  password.toggleMask(true);
62
- expect(passwordElement.type).toEqual('password');
62
+ expect(passwordElement.type).toBe('password');
63
63
  });
64
64
  });
65
65
  });
@@ -111,7 +111,7 @@ describe('PaymentTerm', () => {
111
111
  price: '£1.01',
112
112
  },
113
113
  });
114
- expect(priceStub.innerHTML).toEqual('£1.01');
114
+ expect(priceStub.innerHTML).toBe('£1.01');
115
115
  });
116
116
 
117
117
  it('replaces the trial price with the correct updated trial price', () => {
@@ -127,7 +127,7 @@ describe('PaymentTerm', () => {
127
127
  trialPrice: '£1.01',
128
128
  },
129
129
  });
130
- expect(trialPriceStub.innerHTML).toEqual('£1.01');
130
+ expect(trialPriceStub.innerHTML).toBe('£1.01');
131
131
  });
132
132
 
133
133
  it('replaces the monthly price with the correct updated monthly price', () => {
@@ -143,7 +143,7 @@ describe('PaymentTerm', () => {
143
143
  monthlyPrice: '£1.01',
144
144
  },
145
145
  });
146
- expect(monthlyPriceStub.innerHTML).toEqual('£1.01');
146
+ expect(monthlyPriceStub.innerHTML).toBe('£1.01');
147
147
  });
148
148
 
149
149
  describe('updating base amount', () => {
@@ -98,7 +98,7 @@ describe('PaymentType', () => {
98
98
  describe('removeError', () => {
99
99
  it('removes a class to the paymentType element', () => {
100
100
  paymentType.removeError();
101
- expect(elementStub.classList.remove).toHaveBeenCalled;
101
+ expect(elementStub.classList.remove).toHaveBeenCalled();
102
102
  });
103
103
  });
104
104
 
@@ -29,17 +29,15 @@ describe('postcode', () => {
29
29
 
30
30
  describe('getPostcodeReferenceByCountry', () => {
31
31
  it('returns postcode by default', () => {
32
- expect(Postcode.getPostcodeReferenceByCountry('GBR')).toEqual('postcode');
32
+ expect(Postcode.getPostcodeReferenceByCountry('GBR')).toBe('postcode');
33
33
  });
34
34
 
35
35
  it('returns zip code when country code is USA', () => {
36
- expect(Postcode.getPostcodeReferenceByCountry('USA')).toEqual('zip code');
36
+ expect(Postcode.getPostcodeReferenceByCountry('USA')).toBe('zip code');
37
37
  });
38
38
 
39
39
  it('returns postal when country code is CAN', () => {
40
- expect(Postcode.getPostcodeReferenceByCountry('CAN')).toEqual(
41
- 'postal code'
42
- );
40
+ expect(Postcode.getPostcodeReferenceByCountry('CAN')).toBe('postal code');
43
41
  });
44
42
  });
45
43
 
@@ -55,7 +53,7 @@ describe('postcode', () => {
55
53
  describe('postcode reference name', () => {
56
54
  it('calls querySelector with [data-reference]', () => {
57
55
  postcode.changePostcodeReferenceForCountry = 'GBR';
58
- expect(querySelectorAllStub).toBeCalledWith(
56
+ expect(querySelectorAllStub).toHaveBeenCalledWith(
59
57
  '[data-reference=postcode]'
60
58
  );
61
59
  });
@@ -102,9 +100,7 @@ describe('postcode', () => {
102
100
  placeholder: 'Enter your zip code',
103
101
  });
104
102
  postcode.changePostcodeReferenceForCountry = 'GBR';
105
- expect(postcode.postcodeInput.placeholder).toEqual(
106
- 'Enter your postcode'
107
- );
103
+ expect(postcode.postcodeInput.placeholder).toBe('Enter your postcode');
108
104
  });
109
105
 
110
106
  it('sets postcode placeholder to `Enter your zip code` when country code is USA', () => {
@@ -112,9 +108,7 @@ describe('postcode', () => {
112
108
  placeholder: 'Enter your postcode',
113
109
  });
114
110
  postcode.changePostcodeReferenceForCountry = 'USA';
115
- expect(postcode.postcodeInput.placeholder).toEqual(
116
- 'Enter your zip code'
117
- );
111
+ expect(postcode.postcodeInput.placeholder).toBe('Enter your zip code');
118
112
  });
119
113
 
120
114
  it('sets postcode placeholder to `Enter your postal code` when country code is Canada', () => {
@@ -122,7 +116,7 @@ describe('postcode', () => {
122
116
  placeholder: 'Enter your zip code',
123
117
  });
124
118
  postcode.changePostcodeReferenceForCountry = 'CAN';
125
- expect(postcode.postcodeInput.placeholder).toEqual(
119
+ expect(postcode.postcodeInput.placeholder).toBe(
126
120
  'Enter your postal code'
127
121
  );
128
122
  });
@@ -12,7 +12,7 @@ describe('salesforce', () => {
12
12
  });
13
13
 
14
14
  it('returns the salesforce name for a country', () => {
15
- expect(isoCodeToSalesforceName('GBR')).toEqual('United Kingdom');
15
+ expect(isoCodeToSalesforceName('GBR')).toBe('United Kingdom');
16
16
  });
17
17
  });
18
18
 
@@ -24,7 +24,7 @@ describe('salesforce', () => {
24
24
  });
25
25
 
26
26
  it('returns the ISO country code for Salesforce country', () => {
27
- expect(salesforceNameToIsoCode('United Kingdom')).toEqual('GBR');
27
+ expect(salesforceNameToIsoCode('United Kingdom')).toBe('GBR');
28
28
  });
29
29
  });
30
30
  });
@@ -51,7 +51,7 @@ describe('Submit', () => {
51
51
 
52
52
  it('updates the innerHTML of the button', () => {
53
53
  submit.updateText(newString);
54
- expect(elementStub.innerHTML).toEqual('test');
54
+ expect(elementStub.innerHTML).toBe('test');
55
55
  });
56
56
  });
57
57
 
@@ -74,13 +74,13 @@ describe('Validation - Util', () => {
74
74
  });
75
75
  validationTest.init();
76
76
 
77
- expect(global.window.onbeforeunload).not.toBeDefined();
77
+ expect(global.window.onbeforeunload).toBeUndefined();
78
78
  });
79
79
  });
80
80
 
81
81
  describe('onbeforeunload', () => {
82
82
  it('returns null by default', () => {
83
- expect(global.window.onbeforeunload()).toBe(null);
83
+ expect(global.window.onbeforeunload()).toBeNull();
84
84
  });
85
85
 
86
86
  it('returns true if the form has changed', () => {
@@ -110,6 +110,7 @@ describe('Zuora', () => {
110
110
  expect(error instanceof Zuora.ZuoraErrorInvalidPaymentType).toBe(true);
111
111
  });
112
112
 
113
+ // eslint-disable-next-line jest/valid-title
113
114
  describe(PaymentType.CREDITCARD, () => {
114
115
  it('calls validate', async () => {
115
116
  window.Z.validate.mockImplementation((callback) =>
@@ -144,6 +145,7 @@ describe('Zuora', () => {
144
145
  });
145
146
  });
146
147
 
148
+ // eslint-disable-next-line jest/valid-title
147
149
  describe(PaymentType.DIRECTDEBIT, () => {
148
150
  it('calls validate', async () => {
149
151
  zuora.onDirectDebitConfirmation = jest.fn((callback) => callback(true));