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

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 (36) hide show
  1. package/__mocks__/@financial-times/o-expander.js +9 -0
  2. package/__mocks__/@financial-times/o-forms-input.js +11 -0
  3. package/__mocks__/@financial-times/o-forms.js +40 -0
  4. package/build-state/npm-shrinkwrap.json +74 -167
  5. package/components/delivery-security-instructions.spec.js +3 -3
  6. package/components/graduation-date.spec.js +8 -8
  7. package/components/payment-term.spec.js +3 -3
  8. package/helpers/index.spec.js +11 -0
  9. package/helpers/ncf-common-data.spec.js +34 -0
  10. package/helpers/ncf-countries.spec.js +136 -0
  11. package/jest.config.js +3 -0
  12. package/package.json +2 -1
  13. package/utils/app-banner.spec.js +68 -0
  14. package/utils/apple-pay.spec.js +177 -0
  15. package/utils/billing-country.spec.js +87 -0
  16. package/utils/billing-postcode.spec.js +138 -0
  17. package/utils/company-name.spec.js +3 -7
  18. package/utils/country.spec.js +87 -0
  19. package/utils/delivery-address-type.spec.js +24 -11
  20. package/utils/delivery-option-messages.spec.js +3 -3
  21. package/utils/delivery-option.spec.js +100 -15
  22. package/utils/delivery-postcode.spec.js +138 -0
  23. package/utils/delivery-start-date.spec.js +177 -0
  24. package/utils/email.spec.js +210 -0
  25. package/utils/event-notifier.spec.js +116 -0
  26. package/utils/form-element.spec.js +71 -0
  27. package/utils/loader.spec.js +161 -0
  28. package/utils/password.spec.js +65 -0
  29. package/utils/payment-term.spec.js +198 -0
  30. package/utils/payment-type.spec.js +136 -0
  31. package/utils/postcode.spec.js +122 -0
  32. package/utils/salesforce.spec.js +30 -0
  33. package/utils/submit.spec.js +81 -0
  34. package/utils/tracking.spec.js +174 -0
  35. package/utils/validation.spec.js +234 -0
  36. package/utils/zuora.spec.js +249 -0
@@ -0,0 +1,138 @@
1
+ const BillingPostcode = require('./billing-postcode');
2
+
3
+ describe('BillingPostcode', () => {
4
+ let billingPostcode;
5
+ let querySelectorStub;
6
+ let querySelectorAllStub;
7
+
8
+ beforeEach(() => {
9
+ const document = {
10
+ querySelector: () => {
11
+ return {
12
+ querySelectorAll: () => {},
13
+ querySelector: () => {},
14
+ };
15
+ },
16
+ };
17
+ billingPostcode = new BillingPostcode(
18
+ document,
19
+ '.ncf #billingPostcodeField'
20
+ );
21
+ querySelectorStub = jest.spyOn(billingPostcode.$el, 'querySelector');
22
+ querySelectorAllStub = jest.spyOn(billingPostcode.$el, 'querySelectorAll');
23
+ });
24
+
25
+ afterEach(() => {
26
+ jest.clearAllMocks();
27
+ });
28
+
29
+ it('returns an element', () => {
30
+ expect(billingPostcode.$el).toBeDefined();
31
+ });
32
+
33
+ describe('changePostcodeReferenceForCountry', () => {
34
+ beforeEach(() => {
35
+ querySelectorStub.mockReturnValue({ innerHTML: '' });
36
+ querySelectorAllStub.mockReturnValue([
37
+ { innerHTML: '' },
38
+ { innerHTML: '' },
39
+ ]);
40
+ });
41
+
42
+ describe('postcode reference name', () => {
43
+ it('calls querySelector with [data-reference]', () => {
44
+ billingPostcode.changePostcodeReferenceForCountry = 'GBR';
45
+ expect(querySelectorAllStub).toHaveBeenCalledWith(
46
+ '[data-reference=postcode]'
47
+ );
48
+ });
49
+
50
+ it('sets postcodeReference to post code by default', () => {
51
+ const expectedResponse = [
52
+ { innerHTML: 'postcode' },
53
+ { innerHTML: 'postcode' },
54
+ ];
55
+ billingPostcode.changePostcodeReferenceForCountry = 'GBR';
56
+ expect(billingPostcode.reference).toEqual(expectedResponse);
57
+ });
58
+
59
+ it('sets postcodeReference to zip code when country code is USA', () => {
60
+ const expectedResponse = [
61
+ { innerHTML: 'zip code' },
62
+ { innerHTML: 'zip code' },
63
+ ];
64
+ billingPostcode.changePostcodeReferenceForCountry = 'USA';
65
+ expect(billingPostcode.reference).toEqual(expectedResponse);
66
+ });
67
+
68
+ it('sets postcodeReference to postal code when country code is Canada', () => {
69
+ const expectedResponse = [
70
+ { innerHTML: 'postal code' },
71
+ { innerHTML: 'postal code' },
72
+ ];
73
+ billingPostcode.changePostcodeReferenceForCountry = 'CAN';
74
+ expect(billingPostcode.reference).toEqual(expectedResponse);
75
+ });
76
+ });
77
+
78
+ describe('placeholder', () => {
79
+ it('calls querySelector with span input', () => {
80
+ querySelectorStub.mockReturnValue({
81
+ placeholder: 'Enter your postcode',
82
+ });
83
+ billingPostcode.changePostcodeReferenceForCountry = 'GBR';
84
+ expect(querySelectorStub).toBeCalledWith('input');
85
+ });
86
+
87
+ it('sets postcode placeholder to `Enter your postcode` by default', () => {
88
+ querySelectorStub.mockReturnValue({
89
+ placeholder: 'Enter your zip code',
90
+ });
91
+ billingPostcode.changePostcodeReferenceForCountry = 'GBR';
92
+ expect(billingPostcode.postcodeInput.placeholder).toEqual(
93
+ 'Enter your postcode'
94
+ );
95
+ });
96
+
97
+ it('sets postcode placeholder to `Enter your zip code` when country code is USA', () => {
98
+ querySelectorStub.mockReturnValue({
99
+ placeholder: 'Enter your postcode',
100
+ });
101
+ billingPostcode.changePostcodeReferenceForCountry = 'USA';
102
+ expect(billingPostcode.postcodeInput.placeholder).toEqual(
103
+ 'Enter your zip code'
104
+ );
105
+ });
106
+
107
+ it('sets postcode placeholder to `Enter your postal code` when country code is Canada', () => {
108
+ querySelectorStub.mockReturnValue({
109
+ placeholder: 'Enter your zip code',
110
+ });
111
+ billingPostcode.changePostcodeReferenceForCountry = 'CAN';
112
+ expect(billingPostcode.postcodeInput.placeholder).toEqual(
113
+ 'Enter your postal code'
114
+ );
115
+ });
116
+ });
117
+ });
118
+
119
+ describe('getPostcodeReferenceByCountry', () => {
120
+ it('returns post code by default ', () => {
121
+ expect(BillingPostcode.getPostcodeReferenceByCountry('ZAR')).toEqual(
122
+ 'postcode'
123
+ );
124
+ });
125
+
126
+ it('returns postal code when country is Canada', () => {
127
+ expect(BillingPostcode.getPostcodeReferenceByCountry('CAN')).toEqual(
128
+ 'postal code'
129
+ );
130
+ });
131
+
132
+ it('returns zip code when country is USA', () => {
133
+ expect(BillingPostcode.getPostcodeReferenceByCountry('USA')).toEqual(
134
+ 'zip code'
135
+ );
136
+ });
137
+ });
138
+ });
@@ -5,25 +5,21 @@ import Enzyme, { mount } from 'enzyme';
5
5
  import Adapter from 'enzyme-adapter-react-16';
6
6
  Enzyme.configure({ adapter: new Adapter() });
7
7
 
8
- const { JSDOM } = require('jsdom');
9
-
10
8
  describe('Company Name - Util', () => {
11
9
  describe('Make Optional/Required using the methods inherited from FormElements', () => {
12
- it('should switch between required and optional the input by adding and removing the related classes', () => {
10
+ it('switches between required and optional the input by adding and removing the related classes', () => {
13
11
  const props = {};
14
12
  const component = mount(
15
13
  <Form>
16
14
  <CompanyName {...props} />
17
15
  </Form>
18
16
  );
19
- const dom = new JSDOM(`
17
+ document.body.innerHTML = `
20
18
  <!DOCTYPE html>
21
19
  <html>
22
20
  <head></head>
23
21
  <body>${component.html()}</body>
24
- </html>
25
- `);
26
- const document = dom.window.document;
22
+ </html>`;
27
23
 
28
24
  const companyNameUtilInstance = new CompanyNameUtil(document);
29
25
  expect(companyNameUtilInstance).toBeDefined();
@@ -0,0 +1,87 @@
1
+ const Country = require('./country');
2
+
3
+ describe('Country', () => {
4
+ let country;
5
+ let documentStub;
6
+ let elementStub;
7
+
8
+ beforeEach(() => {
9
+ elementStub = {
10
+ addEventListener: jest.fn(),
11
+ selectedIndex: 1,
12
+ options: [{ value: 0 }, { value: 1 }, { value: 2 }],
13
+ };
14
+ documentStub = {
15
+ querySelector: jest.fn(),
16
+ };
17
+ });
18
+
19
+ afterEach(() => {
20
+ jest.clearAllMocks();
21
+ });
22
+
23
+ describe('constructor', () => {
24
+ it('throws an error if nothing passed', () => {
25
+ expect(() => {
26
+ new Country();
27
+ }).toThrow();
28
+ });
29
+
30
+ it('throws an error if field not present', () => {
31
+ expect(() => {
32
+ documentStub.querySelector.mockReturnValue(false);
33
+ new Country(documentStub);
34
+ }).toThrow();
35
+ });
36
+ });
37
+
38
+ describe('constructed', () => {
39
+ beforeEach(() => {
40
+ documentStub.querySelector.mockReturnValue(elementStub);
41
+ country = new Country(documentStub);
42
+ });
43
+
44
+ describe('onChange', () => {
45
+ it('adds an event listener on change', () => {
46
+ country.onChange();
47
+ expect(elementStub.addEventListener).toHaveBeenCalledWith(
48
+ 'change',
49
+ expect.anything()
50
+ );
51
+ });
52
+
53
+ it('calls the callback', () => {
54
+ const callback = jest.fn();
55
+ elementStub.addEventListener = (type, callback) => callback();
56
+ country.onChange(callback);
57
+ expect(callback).toHaveBeenCalled();
58
+ });
59
+ });
60
+
61
+ describe('getSelected', () => {
62
+ it('throws an error if nothing selected', () => {
63
+ elementStub.options = [];
64
+ elementStub.selectedIndex = 0;
65
+ expect(() => {
66
+ country.getSelected();
67
+ }).toThrow();
68
+ });
69
+
70
+ it('throws an error if something selected that is not there', () => {
71
+ elementStub.selectedIndex = 4;
72
+ expect(() => {
73
+ country.getSelected();
74
+ }).toThrow();
75
+ });
76
+
77
+ it('returns the selected option', () => {
78
+ expect(country.getSelected()).toBe(1);
79
+ });
80
+
81
+ it('returns the changed selected option', () => {
82
+ elementStub.selectedIndex = 0;
83
+ expect(country.getSelected()).toBe(0);
84
+ });
85
+ });
86
+ });
87
+ });
@@ -5,43 +5,56 @@ import Enzyme, { mount } from 'enzyme';
5
5
  import Adapter from 'enzyme-adapter-react-16';
6
6
  Enzyme.configure({ adapter: new Adapter() });
7
7
 
8
- const { JSDOM } = require('jsdom');
9
-
10
8
  describe('Delivery Address Type - Util', () => {
11
9
  describe('Get an instance of the util class', () => {
12
- it('should throw an error since the component is not found', () => {
10
+ it('throws an error since the component is not found', () => {
13
11
  const component = mount(<Form></Form>);
14
- const jsdom = JSDOM.fragment(component.html());
12
+ document.body.innerHTML = `
13
+ <!DOCTYPE html>
14
+ <html>
15
+ <head></head>
16
+ <body>${component.html()}</body>
17
+ </html>`;
15
18
 
16
19
  expect(() => {
17
- new DeliveryAdressTypeUtil(jsdom);
20
+ new DeliveryAdressTypeUtil(document);
18
21
  }).toThrow();
19
22
  });
20
23
  });
21
24
  describe('Get option selected', () => {
22
- it('should return the default option', () => {
25
+ it('returns the default option', () => {
23
26
  const props = {};
24
27
  const component = mount(
25
28
  <Form>
26
29
  <DeliveryAddressType {...props} />
27
30
  </Form>
28
31
  );
29
- const jsdom = JSDOM.fragment(component.html());
32
+ document.body.innerHTML = `
33
+ <!DOCTYPE html>
34
+ <html>
35
+ <head></head>
36
+ <body>${component.html()}</body>
37
+ </html>`;
30
38
 
31
- const deliveryAdressTypeUtilInstance = new DeliveryAdressTypeUtil(jsdom);
39
+ const deliveryAdressTypeUtilInstance = new DeliveryAdressTypeUtil(document);
32
40
  expect(deliveryAdressTypeUtilInstance.getSelected()).toEqual('home');
33
41
  });
34
42
 
35
- it('should return the option selected different than the default', () => {
43
+ it('returns the option selected different than the default', () => {
36
44
  const props = { value: 'pobox' };
37
45
  const component = mount(
38
46
  <Form>
39
47
  <DeliveryAddressType {...props} />
40
48
  </Form>
41
49
  );
42
- const jsdom = JSDOM.fragment(component.html());
50
+ document.body.innerHTML = `
51
+ <!DOCTYPE html>
52
+ <html>
53
+ <head></head>
54
+ <body>${component.html()}</body>
55
+ </html>`;
43
56
 
44
- const deliveryAdressTypeUtilInstance = new DeliveryAdressTypeUtil(jsdom);
57
+ const deliveryAdressTypeUtilInstance = new DeliveryAdressTypeUtil(document);
45
58
  expect(deliveryAdressTypeUtilInstance.getSelected()).toEqual(props.value);
46
59
  });
47
60
  });
@@ -12,20 +12,20 @@ describe('Find Custom Delivery Option', () => {
12
12
  stubOption.mailDelivery = false;
13
13
  });
14
14
 
15
- it('should return undefined when other country than custom messages', () => {
15
+ it('returns undefined when other country than custom messages', () => {
16
16
  expect(
17
17
  getDeliveryOption(sixDaysProductCode, stubOption, 'AAA')
18
18
  ).toBeUndefined();
19
19
  });
20
20
 
21
- it('should return undefined when invalid distributor type code', () => {
21
+ it('returns undefined when invalid distributor type code', () => {
22
22
  const option = { ...stubOption, value: 'ZZ' };
23
23
  expect(
24
24
  getDeliveryOption(sixDaysProductCode, option, 'USA')
25
25
  ).toBeUndefined();
26
26
  });
27
27
 
28
- it('should return undefined when mailDelivery is false and not other required props are setup', () => {
28
+ it('returns undefined when mailDelivery is false and not other required props are setup', () => {
29
29
  stubOption.deliveryOnPublicationDate = undefined;
30
30
  stubOption.flightMarket = undefined;
31
31
  expect(
@@ -5,27 +5,23 @@ import Enzyme, { mount } from 'enzyme';
5
5
  import Adapter from 'enzyme-adapter-react-16';
6
6
  Enzyme.configure({ adapter: new Adapter() });
7
7
 
8
- const { JSDOM } = require('jsdom');
9
-
10
8
  describe('Delivery Option - Util', () => {
11
9
  describe('Get an instance of the util class', () => {
12
- it('should throw an error since the component is not found', () => {
13
- const dom = new JSDOM(`
14
- <!DOCTYPE html>
15
- <html>
16
- <head></head>
17
- <body></body>
18
- </html>
19
- `);
20
- const document = dom.window.document;
10
+ it('throws an error if document element isn not passed in', () => {
11
+ expect(() => {
12
+ new DeliveryOptionUtil();
13
+ }).toThrow();
14
+ });
21
15
 
16
+ it('throws an error since the component is not found', () => {
22
17
  expect(() => {
23
18
  new DeliveryOptionUtil(document);
24
19
  }).toThrow();
25
20
  });
26
21
  });
22
+
27
23
  describe('Show/Hide Items for Delivery Option Change', () => {
28
- it('should swap between hide and show two items by adding and removing the related classes', () => {
24
+ it('swapes between hide and show two items by adding and removing the related classes', () => {
29
25
  const props = {
30
26
  country: 'GBR',
31
27
  options: [
@@ -38,14 +34,13 @@ describe('Delivery Option - Util', () => {
38
34
  <DeliveryOption {...props} />
39
35
  </Form>
40
36
  );
41
- const dom = new JSDOM(`
37
+ document.body.innerHTML = `
42
38
  <!DOCTYPE html>
43
39
  <html>
44
40
  <head></head>
45
41
  <body>${component.html()}</body>
46
42
  </html>
47
- `);
48
- const document = dom.window.document;
43
+ `;
49
44
 
50
45
  const deliveryoptionUtilInstance = new DeliveryOptionUtil(document);
51
46
  expect(deliveryoptionUtilInstance).toBeDefined();
@@ -61,4 +56,94 @@ describe('Delivery Option - Util', () => {
61
56
  expect(document.querySelector('.ncf__hidden #HD')).toBe(null);
62
57
  });
63
58
  });
59
+
60
+ describe('handleDeliveryOptionChange', () => {
61
+ let deliveryOption1Listener;
62
+ let deliveryOption2Listener;
63
+ let formStub;
64
+
65
+ beforeEach(() => {
66
+ deliveryOption1Listener = jest.fn();
67
+ deliveryOption2Listener = jest.fn();
68
+
69
+ formStub = {
70
+ elements: {
71
+ deliveryOption: [
72
+ { addEventListener: deliveryOption1Listener },
73
+ { addEventListener: deliveryOption2Listener },
74
+ ],
75
+ },
76
+ };
77
+
78
+ document.querySelector = jest.fn(() => formStub);
79
+ document.querySelectorAll = jest.fn(() => []);
80
+ });
81
+
82
+ afterEach(() => {
83
+ jest.clearAllMocks();
84
+ });
85
+
86
+ describe('can handle an array', () => {
87
+ it('binds the given callback to the change event on the delivery option fields', async () => {
88
+ let deliveryOptionUtil = new DeliveryOptionUtil(document);
89
+ let callback = jest.fn();
90
+ deliveryOptionUtil.handleDeliveryOptionChange(callback);
91
+
92
+ expect(deliveryOption1Listener).toHaveBeenCalledWith(
93
+ 'change',
94
+ callback
95
+ );
96
+ expect(deliveryOption2Listener).toHaveBeenCalledWith(
97
+ 'change',
98
+ callback
99
+ );
100
+ });
101
+ });
102
+
103
+ describe('can handle a single node element', () => {
104
+ let deliveryOptionUtil;
105
+ let callback;
106
+
107
+ beforeEach(() => {
108
+ const props = {
109
+ country: 'GBR',
110
+ options: [
111
+ { value: 'HD', isSelected: true, isValidDeliveryOption: true },
112
+ { value: 'PV', isSelected: false, isValidDeliveryOption: true },
113
+ ],
114
+ };
115
+ const component = mount(
116
+ <Form>
117
+ <DeliveryOption {...props} />
118
+ </Form>
119
+ );
120
+ document.body.innerHTML = `
121
+ <!DOCTYPE html>
122
+ <html>
123
+ <head></head>
124
+ <body>${component.html()}</body>
125
+ </html>
126
+ `;
127
+
128
+ document.querySelector = jest.fn(() => formStub);
129
+
130
+ deliveryOptionUtil = new DeliveryOptionUtil(document);
131
+ callback = jest.fn();
132
+ });
133
+
134
+ it('can handle having only one form element', () => {
135
+ expect(() => {
136
+ deliveryOptionUtil.handleDeliveryOptionChange(callback);
137
+ }).not.toThrow();
138
+ });
139
+
140
+ it('adds the event listener', () => {
141
+ jest.spyOn(formStub.elements.deliveryOption[0], 'addEventListener');
142
+ deliveryOptionUtil.handleDeliveryOptionChange(callback);
143
+ expect(
144
+ formStub.elements.deliveryOption[0].addEventListener
145
+ ).toHaveBeenCalledWith('change', callback);
146
+ });
147
+ });
148
+ });
64
149
  });
@@ -0,0 +1,138 @@
1
+ const DeliveryPostcode = require('./delivery-postcode');
2
+
3
+ describe('DeliveryPostcode', () => {
4
+ let deliveryPostcode;
5
+ let querySelectorStub;
6
+ let querySelectorAllStub;
7
+
8
+ beforeEach(() => {
9
+ const document = {
10
+ querySelector: () => {
11
+ return {
12
+ querySelectorAll: () => {},
13
+ querySelector: () => {},
14
+ };
15
+ },
16
+ };
17
+ deliveryPostcode = new DeliveryPostcode(
18
+ document,
19
+ '.ncf #deliveryPostcodeField'
20
+ );
21
+ querySelectorStub = jest.spyOn(deliveryPostcode.$el, 'querySelector');
22
+ querySelectorAllStub = jest.spyOn(deliveryPostcode.$el, 'querySelectorAll');
23
+ });
24
+
25
+ afterEach(() => {
26
+ jest.clearAllMocks();
27
+ });
28
+
29
+ it('returns an element', () => {
30
+ expect(deliveryPostcode.$el).toBeDefined();
31
+ });
32
+
33
+ describe('changePostcodeReferenceForCountry', () => {
34
+ beforeEach(() => {
35
+ querySelectorStub.mockReturnValue({ innerHTML: '' });
36
+ querySelectorAllStub.mockReturnValue([
37
+ { innerHTML: '' },
38
+ { innerHTML: '' },
39
+ ]);
40
+ });
41
+
42
+ describe('postcode reference name', () => {
43
+ it('calls querySelector with [data-reference]', () => {
44
+ deliveryPostcode.changePostcodeReferenceForCountry = 'GBR';
45
+ expect(querySelectorAllStub).toHaveBeenCalledWith(
46
+ '[data-reference=postcode]'
47
+ );
48
+ });
49
+
50
+ it('sets postcodeReference to post code by default', () => {
51
+ const expectedResponse = [
52
+ { innerHTML: 'postcode' },
53
+ { innerHTML: 'postcode' },
54
+ ];
55
+ deliveryPostcode.changePostcodeReferenceForCountry = 'GBR';
56
+ expect(deliveryPostcode.reference).toEqual(expectedResponse);
57
+ });
58
+
59
+ it('sets postcodeReference to zip code when country code is USA', () => {
60
+ const expectedResponse = [
61
+ { innerHTML: 'zip code' },
62
+ { innerHTML: 'zip code' },
63
+ ];
64
+ deliveryPostcode.changePostcodeReferenceForCountry = 'USA';
65
+ expect(deliveryPostcode.reference).toEqual(expectedResponse);
66
+ });
67
+
68
+ it('sets postcodeReference to postal code when country code is Canada', () => {
69
+ const expectedResponse = [
70
+ { innerHTML: 'postal code' },
71
+ { innerHTML: 'postal code' },
72
+ ];
73
+ deliveryPostcode.changePostcodeReferenceForCountry = 'CAN';
74
+ expect(deliveryPostcode.reference).toEqual(expectedResponse);
75
+ });
76
+ });
77
+
78
+ describe('placeholder', () => {
79
+ it('calls querySelector with span input', () => {
80
+ querySelectorStub.mockReturnValue({
81
+ placeholder: 'Enter your postcode',
82
+ });
83
+ deliveryPostcode.changePostcodeReferenceForCountry = 'GBR';
84
+ expect(querySelectorStub).toHaveBeenCalledWith('input');
85
+ });
86
+
87
+ it('sets postcode placeholder to `Enter your postcode` by default', () => {
88
+ querySelectorStub.mockReturnValue({
89
+ placeholder: 'Enter your zip code',
90
+ });
91
+ deliveryPostcode.changePostcodeReferenceForCountry = 'GBR';
92
+ expect(deliveryPostcode.postcodeInput.placeholder).toEqual(
93
+ 'Enter your postcode'
94
+ );
95
+ });
96
+
97
+ it('sets postcode placeholder to `Enter your zip code` when country code is USA', () => {
98
+ querySelectorStub.mockReturnValue({
99
+ placeholder: 'Enter your postcode',
100
+ });
101
+ deliveryPostcode.changePostcodeReferenceForCountry = 'USA';
102
+ expect(deliveryPostcode.postcodeInput.placeholder).toEqual(
103
+ 'Enter your zip code'
104
+ );
105
+ });
106
+
107
+ it('sets postcode placeholder to `Enter your postal code` when country code is Canada', () => {
108
+ querySelectorStub.mockReturnValue({
109
+ placeholder: 'Enter your zip code',
110
+ });
111
+ deliveryPostcode.changePostcodeReferenceForCountry = 'CAN';
112
+ expect(deliveryPostcode.postcodeInput.placeholder).toEqual(
113
+ 'Enter your postal code'
114
+ );
115
+ });
116
+ });
117
+ });
118
+
119
+ describe('getPostcodeReferenceByCountry', () => {
120
+ it('returns post code by default ', () => {
121
+ expect(DeliveryPostcode.getPostcodeReferenceByCountry('ZAR')).toEqual(
122
+ 'postcode'
123
+ );
124
+ });
125
+
126
+ it('returns postal code when country is Canada', () => {
127
+ expect(DeliveryPostcode.getPostcodeReferenceByCountry('CAN')).toEqual(
128
+ 'postal code'
129
+ );
130
+ });
131
+
132
+ it('returns zip code when country is USA', () => {
133
+ expect(DeliveryPostcode.getPostcodeReferenceByCountry('USA')).toEqual(
134
+ 'zip code'
135
+ );
136
+ });
137
+ });
138
+ });