@financial-times/n-conversion-forms 28.8.0 → 28.9.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.
@@ -406,6 +406,7 @@ PaymentTerm.propTypes = {
406
406
  subTitle: PropTypes.string,
407
407
  bestOffer: PropTypes.bool,
408
408
  chargeOnText: PropTypes.string,
409
+ fulfilmentOption: PropTypes.string,
409
410
  })
410
411
  ),
411
412
  isFixedTermOffer: PropTypes.bool,
@@ -288,7 +288,8 @@ PaymentTerm.propTypes = {
288
288
  title: _propTypes["default"].string,
289
289
  subTitle: _propTypes["default"].string,
290
290
  bestOffer: _propTypes["default"].bool,
291
- chargeOnText: _propTypes["default"].string
291
+ chargeOnText: _propTypes["default"].string,
292
+ fulfilmentOption: _propTypes["default"].string
292
293
  })),
293
294
  isFixedTermOffer: _propTypes["default"].bool,
294
295
  offerDisplayName: _propTypes["default"].string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "28.8.0",
3
+ "version": "28.9.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": {
@@ -104,8 +104,9 @@ class PaymentTerm {
104
104
  }
105
105
 
106
106
  /**
107
- * Update the payment term options
108
- * @param {Array} options Array of objects contain terms information
107
+ * Updates the payment term options.
108
+ * @param {Object} options - indexed Object about Array of objects containing terms information. E.g.: { P1Y: {...}, P3M: {...}}
109
+ * @throws Will throw an error if a payment term update is not found for a given value.
109
110
  */
110
111
  updateOptions(options) {
111
112
  const terms = this.$paymentTerm.querySelectorAll(ITEM_CLASS);
@@ -115,7 +116,7 @@ class PaymentTerm {
115
116
  const price = term.querySelector(PRICE_CLASS);
116
117
  const trialPrice = term.querySelector(TRIAL_PRICE_CLASS);
117
118
  const monthlyPrice = term.querySelector(MONTHLY_PRICE_CLASS);
118
- const update = options.find((option) => option.value === value);
119
+ const update = options[value];
119
120
 
120
121
  if (!update) {
121
122
  throw new Error(`Payment term update not found for "${value}"`);
@@ -94,7 +94,7 @@ describe('PaymentTerm', () => {
94
94
 
95
95
  it('throws an error if not all terms have an update', () => {
96
96
  expect(() => {
97
- paymentTerm.updateOptions([]);
97
+ paymentTerm.updateOptions({});
98
98
  }).toThrow();
99
99
  });
100
100
 
@@ -105,12 +105,12 @@ describe('PaymentTerm', () => {
105
105
  ? priceStub
106
106
  : elementStub;
107
107
  });
108
- paymentTerm.updateOptions([
109
- {
108
+ paymentTerm.updateOptions({
109
+ test: {
110
110
  value: 'test',
111
111
  price: '£1.01',
112
112
  },
113
- ]);
113
+ });
114
114
  expect(priceStub.innerHTML).toEqual('£1.01');
115
115
  });
116
116
 
@@ -121,12 +121,12 @@ describe('PaymentTerm', () => {
121
121
  ? trialPriceStub
122
122
  : elementStub;
123
123
  });
124
- paymentTerm.updateOptions([
125
- {
124
+ paymentTerm.updateOptions({
125
+ test: {
126
126
  value: 'test',
127
127
  trialPrice: '£1.01',
128
128
  },
129
- ]);
129
+ });
130
130
  expect(trialPriceStub.innerHTML).toEqual('£1.01');
131
131
  });
132
132
 
@@ -137,31 +137,31 @@ describe('PaymentTerm', () => {
137
137
  ? monthlyPriceStub
138
138
  : elementStub;
139
139
  });
140
- paymentTerm.updateOptions([
141
- {
140
+ paymentTerm.updateOptions({
141
+ test: {
142
142
  value: 'test',
143
143
  monthlyPrice: '£1.01',
144
144
  },
145
- ]);
145
+ });
146
146
  expect(monthlyPriceStub.innerHTML).toEqual('£1.01');
147
147
  });
148
148
 
149
149
  describe('updating base amount', () => {
150
- const updatedOptions = [
151
- {
150
+ const updatedOptions = {
151
+ test: {
152
152
  value: 'test',
153
153
  monthlyPrice: '£1.01',
154
154
  amount: 500,
155
155
  trialAmount: 1,
156
156
  },
157
- ];
157
+ };
158
158
 
159
159
  beforeEach(() => {
160
160
  elementStub.querySelector.mockReturnValue(elementStub);
161
161
  });
162
162
 
163
163
  it('replaces the base amount with the correct updated trial amount', () => {
164
- updatedOptions[0].isTrial = true;
164
+ updatedOptions.test.isTrial = true;
165
165
  paymentTerm.updateOptions(updatedOptions);
166
166
  expect(elementStub.setAttribute).toHaveBeenCalledWith(
167
167
  'data-base-amount',
@@ -170,7 +170,7 @@ describe('PaymentTerm', () => {
170
170
  });
171
171
 
172
172
  it('replaces the base amount with the correct updated amount', () => {
173
- updatedOptions[0].isTrial = false;
173
+ updatedOptions.test.isTrial = false;
174
174
  paymentTerm.updateOptions(updatedOptions);
175
175
  expect(elementStub.setAttribute).toHaveBeenCalledWith(
176
176
  'data-base-amount',