@financial-times/n-conversion-forms 23.0.2 → 23.0.5

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.
@@ -22,13 +22,13 @@ references:
22
22
 
23
23
  npm_cache_keys: &npm_cache_keys
24
24
  keys:
25
- - v2-dependency-npm-{{ checksum "package.json" }}-
26
- - v2-dependency-npm-{{ checksum "package.json" }}
27
- - v2-dependency-npm-
25
+ - v3-dependency-npm-{{ checksum "package.json" }}-
26
+ - v3-dependency-npm-{{ checksum "package.json" }}
27
+ - v3-dependency-npm-
28
28
 
29
29
  cache_npm_cache: &cache_npm_cache
30
30
  save_cache:
31
- key: v2-dependency-npm-{{ checksum "package.json" }}-{{ epoch }}
31
+ key: v3-dependency-npm-{{ checksum "package.json" }}-{{ epoch }}
32
32
  paths:
33
33
  - ./node_modules/
34
34
 
@@ -14,7 +14,7 @@
14
14
  "classnames": "2.3.1",
15
15
  "fetchres": "1.7.2",
16
16
  "lodash.get": "4.4.2",
17
- "n-common-static-data": "financial-times/n-common-static-data#v1.6.1"
17
+ "n-common-static-data": "github:Financial-Times/n-common-static-data#v1.7.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "@babel/cli": "^7.10.5",
@@ -25134,9 +25134,11 @@
25134
25134
  },
25135
25135
  "node_modules/n-common-static-data": {
25136
25136
  "version": "1.0.0",
25137
- "resolved": "git+ssh://git@github.com/financial-times/n-common-static-data.git#f20f8476d37b1694134c4bc5ba72bfeb75ea2565",
25137
+ "resolved": "git+ssh://git@github.com/Financial-Times/n-common-static-data.git#bc4ac35d786ed747f026a5e131dd1ce80d746d6a",
25138
+ "hasInstallScript": true,
25138
25139
  "engines": {
25139
- "node": "^6.11.0"
25140
+ "node": "12.x || 14.x || 16.x",
25141
+ "npm": "7.x || 8.x"
25140
25142
  }
25141
25143
  },
25142
25144
  "node_modules/nan": {
@@ -56318,8 +56320,8 @@
56318
56320
  }
56319
56321
  },
56320
56322
  "n-common-static-data": {
56321
- "version": "git+ssh://git@github.com/financial-times/n-common-static-data.git#f20f8476d37b1694134c4bc5ba72bfeb75ea2565",
56322
- "from": "n-common-static-data@financial-times/n-common-static-data#v1.6.1"
56323
+ "version": "git+ssh://git@github.com/Financial-Times/n-common-static-data.git#bc4ac35d786ed747f026a5e131dd1ce80d746d6a",
56324
+ "from": "n-common-static-data@github:Financial-Times/n-common-static-data#v1.7.1"
56323
56325
  },
56324
56326
  "nan": {
56325
56327
  "version": "2.15.0",
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { demographics } from 'n-common-static-data';
5
- const defaultOptions = demographics.positions.positions;
4
+ import { b2b, demographics } from 'n-common-static-data';
5
+ const B2CPositions = demographics.positions.positions;
6
+ const B2BPositions = b2b.demographics.positions.positions;
6
7
 
7
8
  export function Position ({
8
9
  value,
@@ -11,7 +12,8 @@ export function Position ({
11
12
  fieldId = 'positionField',
12
13
  selectId = 'position',
13
14
  selectName = 'position',
14
- options = defaultOptions,
15
+ isB2B = false,
16
+ options = isB2B ? B2BPositions : B2CPositions,
15
17
  isRequired = true,
16
18
  fieldLabel = 'What’s your job position?',
17
19
  }) {
@@ -70,6 +72,7 @@ Position.propTypes = {
70
72
  fieldId: PropTypes.string,
71
73
  selectId: PropTypes.string,
72
74
  selectName: PropTypes.string,
75
+ isB2B: PropTypes.bool,
73
76
  options: PropTypes.arrayOf(
74
77
  PropTypes.shape({
75
78
  code: PropTypes.string,
@@ -1,7 +1,7 @@
1
1
  import { Position } from './index';
2
2
  import { expectToRenderCorrectly } from '../test-jest/helpers/expect-to-render-correctly';
3
3
  import { demographics } from 'n-common-static-data';
4
- const defaultOptions = demographics.positions.positions;
4
+ const B2CPositions = demographics.positions.positions;
5
5
 
6
6
  import Enzyme, { mount } from 'enzyme';
7
7
  import Adapter from 'enzyme-adapter-react-16';
@@ -12,7 +12,7 @@ expect.extend(expectToRenderCorrectly);
12
12
  describe('Position', () => {
13
13
  it('render a select with a label', () => {
14
14
  const props = {
15
- options: defaultOptions,
15
+ options: B2CPositions,
16
16
  };
17
17
 
18
18
  expect(Position).toRenderCorrectly(props);
@@ -20,7 +20,7 @@ describe('Position', () => {
20
20
 
21
21
  it('can render an initial selected value', () => {
22
22
  const props = {
23
- options: defaultOptions,
23
+ options: B2CPositions,
24
24
  value: 'CP',
25
25
  };
26
26
 
@@ -29,7 +29,7 @@ describe('Position', () => {
29
29
 
30
30
  it('can render a disable select', () => {
31
31
  const props = {
32
- options: defaultOptions,
32
+ options: B2CPositions,
33
33
  isDisabled: true,
34
34
  };
35
35
 
@@ -38,7 +38,7 @@ describe('Position', () => {
38
38
 
39
39
  it('can render an error message', () => {
40
40
  const props = {
41
- options: defaultOptions,
41
+ options: B2CPositions,
42
42
  hasError: true,
43
43
  };
44
44
 
@@ -68,4 +68,14 @@ describe('Position', () => {
68
68
  component.find('.o-forms-title.o-forms-field--optional').length
69
69
  ).toEqual(1);
70
70
  });
71
+
72
+ it('defaults to B2B options if isB2B is true', () => {
73
+ const props = { isB2B: true };
74
+ const component = mount(Position(props));
75
+
76
+ // Look for an option which is only present in the default B2B data set and not in the B2C one.
77
+ const optionValue = component.find('option').at(1).instance().value;
78
+
79
+ expect(optionValue).toBe('OW');
80
+ });
71
81
  });
@@ -1,8 +1,9 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classNames from 'classnames';
4
- import { demographics } from 'n-common-static-data';
5
- const defaultOptions = demographics.responsibilities.responsibilities;
4
+ import { b2b, demographics } from 'n-common-static-data';
5
+ const B2CResponsibilities = demographics.responsibilities.responsibilities;
6
+ const B2BResponsibilities = b2b.demographics.responsibilities.responsibilities;
6
7
 
7
8
  export function Responsibility ({
8
9
  value,
@@ -12,7 +13,8 @@ export function Responsibility ({
12
13
  fieldId = 'responsibilityField',
13
14
  selectId = 'responsibility',
14
15
  selectName = 'responsibility',
15
- options = defaultOptions,
16
+ isB2B = false,
17
+ options = isB2B ? B2BResponsibilities : B2CResponsibilities,
16
18
  fieldLabel = 'Which best describes your job responsibility?',
17
19
  }) {
18
20
  const inputWrapperClassName = classNames([
@@ -72,6 +74,7 @@ Responsibility.propTypes = {
72
74
  fieldId: PropTypes.string,
73
75
  selectId: PropTypes.string,
74
76
  selectName: PropTypes.string,
77
+ isB2B: PropTypes.bool,
75
78
  options: PropTypes.arrayOf(
76
79
  PropTypes.shape({
77
80
  code: PropTypes.string,
@@ -1,7 +1,7 @@
1
1
  import { Responsibility } from './index';
2
2
  import { expectToRenderCorrectly } from '../test-jest/helpers/expect-to-render-correctly';
3
3
  import { demographics } from 'n-common-static-data';
4
- const defaultOptions = demographics.responsibilities.responsibilities;
4
+ const B2CResponsibilities = demographics.responsibilities.responsibilities;
5
5
 
6
6
  import Enzyme, { mount } from 'enzyme';
7
7
  import Adapter from 'enzyme-adapter-react-16';
@@ -12,7 +12,7 @@ expect.extend(expectToRenderCorrectly);
12
12
  describe('Responsibility', () => {
13
13
  it('render a select with a label', () => {
14
14
  const props = {
15
- options: defaultOptions,
15
+ options: B2CResponsibilities,
16
16
  };
17
17
 
18
18
  expect(Responsibility).toRenderCorrectly(props);
@@ -20,7 +20,7 @@ describe('Responsibility', () => {
20
20
 
21
21
  it('can render an initial selected value', () => {
22
22
  const props = {
23
- options: defaultOptions,
23
+ options: B2CResponsibilities,
24
24
  value: 'FIN',
25
25
  };
26
26
 
@@ -29,7 +29,7 @@ describe('Responsibility', () => {
29
29
 
30
30
  it('can render a disable select', () => {
31
31
  const props = {
32
- options: defaultOptions,
32
+ options: B2CResponsibilities,
33
33
  isDisabled: true,
34
34
  };
35
35
 
@@ -38,7 +38,7 @@ describe('Responsibility', () => {
38
38
 
39
39
  it('can render an error message', () => {
40
40
  const props = {
41
- options: defaultOptions,
41
+ options: B2CResponsibilities,
42
42
  hasError: true,
43
43
  };
44
44
 
@@ -74,4 +74,14 @@ describe('Responsibility', () => {
74
74
  component.find('.o-forms-title.o-forms-field--optional').length
75
75
  ).toEqual(1);
76
76
  });
77
+
78
+ it('defaults to B2B options if isB2B is true', () => {
79
+ const props = { isB2B: true };
80
+ const component = mount(Responsibility(props));
81
+
82
+ // Look for an option which is only present in the default B2B data set and not in the B2C one.
83
+ const optionValue = component.find('option').at(1).instance().value;
84
+
85
+ expect(optionValue).toBe('ACC');
86
+ });
77
87
  });
package/dist/position.js CHANGED
@@ -15,7 +15,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
16
  var _nCommonStaticData = require("n-common-static-data");
17
17
 
18
- var defaultOptions = _nCommonStaticData.demographics.positions.positions;
18
+ var B2CPositions = _nCommonStaticData.demographics.positions.positions;
19
+ var B2BPositions = _nCommonStaticData.b2b.demographics.positions.positions;
19
20
 
20
21
  function Position(_ref) {
21
22
  var value = _ref.value,
@@ -29,8 +30,10 @@ function Position(_ref) {
29
30
  selectId = _ref$selectId === void 0 ? 'position' : _ref$selectId,
30
31
  _ref$selectName = _ref.selectName,
31
32
  selectName = _ref$selectName === void 0 ? 'position' : _ref$selectName,
33
+ _ref$isB2B = _ref.isB2B,
34
+ isB2B = _ref$isB2B === void 0 ? false : _ref$isB2B,
32
35
  _ref$options = _ref.options,
33
- options = _ref$options === void 0 ? defaultOptions : _ref$options,
36
+ options = _ref$options === void 0 ? isB2B ? B2BPositions : B2CPositions : _ref$options,
34
37
  _ref$isRequired = _ref.isRequired,
35
38
  isRequired = _ref$isRequired === void 0 ? true : _ref$isRequired,
36
39
  _ref$fieldLabel = _ref.fieldLabel,
@@ -81,6 +84,7 @@ Position.propTypes = {
81
84
  fieldId: _propTypes["default"].string,
82
85
  selectId: _propTypes["default"].string,
83
86
  selectName: _propTypes["default"].string,
87
+ isB2B: _propTypes["default"].bool,
84
88
  options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
85
89
  code: _propTypes["default"].string,
86
90
  description: _propTypes["default"].string
@@ -15,7 +15,8 @@ var _classnames = _interopRequireDefault(require("classnames"));
15
15
 
16
16
  var _nCommonStaticData = require("n-common-static-data");
17
17
 
18
- var defaultOptions = _nCommonStaticData.demographics.responsibilities.responsibilities;
18
+ var B2CResponsibilities = _nCommonStaticData.demographics.responsibilities.responsibilities;
19
+ var B2BResponsibilities = _nCommonStaticData.b2b.demographics.responsibilities.responsibilities;
19
20
 
20
21
  function Responsibility(_ref) {
21
22
  var value = _ref.value,
@@ -31,8 +32,10 @@ function Responsibility(_ref) {
31
32
  selectId = _ref$selectId === void 0 ? 'responsibility' : _ref$selectId,
32
33
  _ref$selectName = _ref.selectName,
33
34
  selectName = _ref$selectName === void 0 ? 'responsibility' : _ref$selectName,
35
+ _ref$isB2B = _ref.isB2B,
36
+ isB2B = _ref$isB2B === void 0 ? false : _ref$isB2B,
34
37
  _ref$options = _ref.options,
35
- options = _ref$options === void 0 ? defaultOptions : _ref$options,
38
+ options = _ref$options === void 0 ? isB2B ? B2BResponsibilities : B2CResponsibilities : _ref$options,
36
39
  _ref$fieldLabel = _ref.fieldLabel,
37
40
  fieldLabel = _ref$fieldLabel === void 0 ? 'Which best describes your job responsibility?' : _ref$fieldLabel;
38
41
  var inputWrapperClassName = (0, _classnames["default"])(['o-forms-input', 'o-forms-input--select', {
@@ -81,6 +84,7 @@ Responsibility.propTypes = {
81
84
  fieldId: _propTypes["default"].string,
82
85
  selectId: _propTypes["default"].string,
83
86
  selectName: _propTypes["default"].string,
87
+ isB2B: _propTypes["default"].bool,
84
88
  options: _propTypes["default"].arrayOf(_propTypes["default"].shape({
85
89
  code: _propTypes["default"].string,
86
90
  description: _propTypes["default"].string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@financial-times/n-conversion-forms",
3
- "version": "23.0.2",
3
+ "version": "23.0.5",
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.1",
30
30
  "fetchres": "1.7.2",
31
31
  "lodash.get": "4.4.2",
32
- "n-common-static-data": "financial-times/n-common-static-data#v1.6.1"
32
+ "n-common-static-data": "github:Financial-Times/n-common-static-data#v1.7.1"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@babel/cli": "^7.10.5",