@financial-times/n-conversion-forms 32.4.0 → 32.6.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "branch": "",
3
3
  "repo": "n-conversion-forms",
4
- "version": "028fb82534567b6f0bb602afb409c47306fd4671",
5
- "tag": "v32.4.0"
4
+ "version": "f5742cc8aa1bf7f00d0c6822afbbc82d90a96103",
5
+ "tag": "v32.6.0"
6
6
  }
@@ -34,7 +34,7 @@ export function PaymentTerm({
34
34
  /**
35
35
  * returns period converted to time if found
36
36
  * otherwise returns empty string to avoid show information not mapped
37
- * @param {string} period (expressed in IS0 8601 duration format): PxY (yearly), PxM (montly), or PxW, where x is the amount of years/months/weeks
37
+ * @param {string} period (expressed in IS0 8601 duration format): PxY (yearly), PxM (montly), PxW (weekly), of PxD (daily), where x is the amount of years/months/weeks/days
38
38
  * @returns {string}
39
39
  */
40
40
  const getTimeFromPeriod = (period) => {
@@ -42,6 +42,7 @@ export function PaymentTerm({
42
42
  Y: 'years',
43
43
  M: 'months',
44
44
  W: 'weeks',
45
+ D: 'days',
45
46
  };
46
47
 
47
48
  const periodUnitCode = period.substring(period.length - 1);
@@ -185,28 +185,58 @@ describe('PaymentTerm', () => {
185
185
  });
186
186
 
187
187
  describe('given isTermedSubscriptionTermType is true', () => {
188
- const options = [
189
- {
190
- name: '8 weeks',
191
- price: '£19.00',
192
- amount: '19.00',
193
- value: 'P8W',
194
- },
195
- ];
196
- const wrapper = shallow(
197
- <PaymentTerm options={options} isTermedSubscriptionTermType={true} />
198
- );
199
-
200
- it('renders subscription term as title', () => {
201
- expect(wrapper.find('.ncf__payment-term__title').text()).toMatch(
202
- '8 weeks'
188
+ describe('options include duration expressed in weeks', () => {
189
+ const options = [
190
+ {
191
+ price: '£19.00',
192
+ amount: '19.00',
193
+ value: 'P8W',
194
+ },
195
+ ];
196
+ const wrapper = shallow(
197
+ <PaymentTerm options={options} isTermedSubscriptionTermType={true} />
203
198
  );
199
+
200
+ it('renders subscription term as title', () => {
201
+ expect(wrapper.find('.ncf__payment-term__title').text()).toMatch(
202
+ '8 weeks'
203
+ );
204
+ });
205
+
206
+ it('renders description text that reflects that the termed subscription requires a single payment that expresses the per duration cost for shorter durations', () => {
207
+ expect(
208
+ wrapper.find('.ncf__payment-term__description').text()
209
+ ).toContain(
210
+ 'Single £19.00 paymentThat’s equivalent to GBP9.50 per month'
211
+ );
212
+ });
204
213
  });
205
214
 
206
- it('renders description text that reflects that the termed subscription requires a single payment that expresses the per duration cost for shorter durations', () => {
207
- expect(wrapper.find('.ncf__payment-term__description').text()).toContain(
208
- 'Single £19.00 paymentThat’s equivalent to GBP9.50 per month'
215
+ describe('options include duration expressed in days', () => {
216
+ const options = [
217
+ {
218
+ price: '£30.00',
219
+ amount: '30.00',
220
+ value: 'P90D',
221
+ },
222
+ ];
223
+ const wrapper = shallow(
224
+ <PaymentTerm options={options} isTermedSubscriptionTermType={true} />
209
225
  );
226
+
227
+ it('renders subscription term as title', () => {
228
+ expect(wrapper.find('.ncf__payment-term__title').text()).toMatch(
229
+ '90 days'
230
+ );
231
+ });
232
+
233
+ it('renders description text that reflects that the termed subscription requires a single payment that expresses the per duration cost for shorter durations', () => {
234
+ expect(
235
+ wrapper.find('.ncf__payment-term__description').text()
236
+ ).toContain(
237
+ 'Single £30.00 paymentThat’s equivalent to GBP10.00 per month'
238
+ );
239
+ });
210
240
  });
211
241
  });
212
242
 
@@ -57,14 +57,15 @@ function PaymentTerm(_ref) {
57
57
  /**
58
58
  * returns period converted to time if found
59
59
  * otherwise returns empty string to avoid show information not mapped
60
- * @param {string} period (expressed in IS0 8601 duration format): PxY (yearly), PxM (montly), or PxW, where x is the amount of years/months/weeks
60
+ * @param {string} period (expressed in IS0 8601 duration format): PxY (yearly), PxM (montly), PxW (weekly), of PxD (daily), where x is the amount of years/months/weeks/days
61
61
  * @returns {string}
62
62
  */
63
63
  var getTimeFromPeriod = function getTimeFromPeriod(period) {
64
64
  var periodUnitCodeToWordMap = {
65
65
  Y: 'years',
66
66
  M: 'months',
67
- W: 'weeks'
67
+ W: 'weeks',
68
+ D: 'days'
68
69
  };
69
70
  var periodUnitCode = period.substring(period.length - 1);
70
71
  var freq = periodUnitCodeToWordMap[periodUnitCode] || '';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "32.4.0",
3
+ "version": "32.6.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": {
@@ -29,7 +29,7 @@
29
29
  "classnames": "2.3.2",
30
30
  "fetchres": "1.7.2",
31
31
  "lodash.get": "4.4.2",
32
- "n-common-static-data": "github:Financial-Times/n-common-static-data#v2.0.0"
32
+ "n-common-static-data": "github:Financial-Times/n-common-static-data#v2.1.0"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/core": "^7.22.15",