@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.
- package/__mocks__/@financial-times/o-expander.js +9 -0
- package/__mocks__/@financial-times/o-forms-input.js +11 -0
- package/__mocks__/@financial-times/o-forms.js +40 -0
- package/build-state/npm-shrinkwrap.json +74 -167
- package/components/delivery-security-instructions.spec.js +3 -3
- package/components/graduation-date.spec.js +8 -8
- package/components/payment-term.spec.js +3 -3
- package/helpers/index.spec.js +11 -0
- package/helpers/ncf-common-data.spec.js +34 -0
- package/helpers/ncf-countries.spec.js +136 -0
- package/jest.config.js +3 -0
- package/package.json +2 -1
- package/utils/app-banner.spec.js +68 -0
- package/utils/apple-pay.spec.js +177 -0
- package/utils/billing-country.spec.js +87 -0
- package/utils/billing-postcode.spec.js +138 -0
- package/utils/company-name.spec.js +3 -7
- package/utils/country.spec.js +87 -0
- package/utils/delivery-address-type.spec.js +24 -11
- package/utils/delivery-option-messages.spec.js +3 -3
- package/utils/delivery-option.spec.js +100 -15
- package/utils/delivery-postcode.spec.js +138 -0
- package/utils/delivery-start-date.spec.js +177 -0
- package/utils/email.spec.js +210 -0
- package/utils/event-notifier.spec.js +116 -0
- package/utils/form-element.spec.js +71 -0
- package/utils/loader.spec.js +161 -0
- package/utils/password.spec.js +65 -0
- package/utils/payment-term.spec.js +198 -0
- package/utils/payment-type.spec.js +136 -0
- package/utils/postcode.spec.js +122 -0
- package/utils/salesforce.spec.js +30 -0
- package/utils/submit.spec.js +81 -0
- package/utils/tracking.spec.js +174 -0
- package/utils/validation.spec.js +234 -0
- package/utils/zuora.spec.js +249 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const Submit = require('./submit');
|
|
2
|
+
|
|
3
|
+
describe('Submit', () => {
|
|
4
|
+
let submit;
|
|
5
|
+
let documentStub;
|
|
6
|
+
let elementStub;
|
|
7
|
+
let newString;
|
|
8
|
+
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
elementStub = {
|
|
11
|
+
querySelector: jest.fn(),
|
|
12
|
+
innerHTML: 'default',
|
|
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 Submit();
|
|
27
|
+
}).toThrow();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('throws an error if button not present', () => {
|
|
31
|
+
expect(() => {
|
|
32
|
+
documentStub.querySelector.mockReturnValue(false);
|
|
33
|
+
new Submit(documentStub);
|
|
34
|
+
}).toThrow();
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('constructed', () => {
|
|
39
|
+
beforeEach(() => {
|
|
40
|
+
newString = 'test';
|
|
41
|
+
documentStub.querySelector.mockReturnValue(elementStub);
|
|
42
|
+
submit = new Submit(documentStub);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('updateText', () => {
|
|
46
|
+
it('throws if no string given', () => {
|
|
47
|
+
expect(() => {
|
|
48
|
+
submit.updateText();
|
|
49
|
+
}).toThrow();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('updates the innerHTML of the button', () => {
|
|
53
|
+
submit.updateText(newString);
|
|
54
|
+
expect(elementStub.innerHTML).toEqual('test');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('enable', () => {
|
|
59
|
+
it('enables the button', () => {
|
|
60
|
+
submit.disable();
|
|
61
|
+
submit.enable();
|
|
62
|
+
expect(submit.$submit.disabled).toBe(false);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('disable', () => {
|
|
67
|
+
it('disables the button', () => {
|
|
68
|
+
submit.disable();
|
|
69
|
+
expect(submit.$submit.disabled).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe('isDisabled', () => {
|
|
74
|
+
it('indicates the disabled state of the button', () => {
|
|
75
|
+
expect(submit.isDisabled()).toBe(false);
|
|
76
|
+
submit.disable();
|
|
77
|
+
expect(submit.isDisabled()).toBe(true);
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
const Tracking = require('./tracking');
|
|
2
|
+
|
|
3
|
+
describe('Tracking', () => {
|
|
4
|
+
let element;
|
|
5
|
+
let window;
|
|
6
|
+
let tracking;
|
|
7
|
+
|
|
8
|
+
beforeEach(() => {
|
|
9
|
+
element = { dispatchEvent: () => {} };
|
|
10
|
+
window = {
|
|
11
|
+
CustomEvent: function () {},
|
|
12
|
+
Image: function () {},
|
|
13
|
+
Date: function () {},
|
|
14
|
+
};
|
|
15
|
+
tracking = new Tracking(window, element);
|
|
16
|
+
|
|
17
|
+
jest.spyOn(tracking, 'dispatchCustomEvent');
|
|
18
|
+
jest.spyOn(tracking, 'dispatchImage');
|
|
19
|
+
jest.spyOn(window, 'CustomEvent');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
jest.clearAllMocks();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('constructor', () => {
|
|
27
|
+
it('throws an error if window not passed', () => {
|
|
28
|
+
expect(() => {
|
|
29
|
+
new Tracking();
|
|
30
|
+
}).toThrow();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('throws an error if element not passed', () => {
|
|
34
|
+
expect(() => {
|
|
35
|
+
new Tracking(window);
|
|
36
|
+
}).toThrow();
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('dispatch', () => {
|
|
41
|
+
describe('parameter validation', () => {
|
|
42
|
+
it('throws an error if nothing passed', () => {
|
|
43
|
+
expect(() => {
|
|
44
|
+
tracking.dispatch();
|
|
45
|
+
}).toThrow();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('throws an error if action is missing', () => {
|
|
49
|
+
expect(() => {
|
|
50
|
+
tracking.dispatch('test');
|
|
51
|
+
}).toThrow();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
describe('dispatch events', () => {
|
|
56
|
+
it('calls dispatchEvent', () => {
|
|
57
|
+
tracking.dispatch('test', 'test');
|
|
58
|
+
expect(tracking.dispatchCustomEvent).toHaveBeenCalled();
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('fallbacks to dispatchImage if dispatchEvent errors', () => {
|
|
62
|
+
tracking.dispatchCustomEvent.mockRestore();
|
|
63
|
+
tracking.dispatchCustomEvent = jest.fn().mockImplementation(() => {
|
|
64
|
+
throw new Error();
|
|
65
|
+
});
|
|
66
|
+
tracking.dispatch('test', 'test');
|
|
67
|
+
expect(tracking.dispatchImage).toHaveBeenCalled();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('extra data', () => {
|
|
72
|
+
it('merges extra tracking data', () => {
|
|
73
|
+
const data = { extra: 'data' };
|
|
74
|
+
tracking.dispatch('test', 'test', data);
|
|
75
|
+
expect(tracking.dispatchCustomEvent).toHaveBeenCalledWith(
|
|
76
|
+
expect.objectContaining(data)
|
|
77
|
+
);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('does not overwrite the given action and test', () => {
|
|
81
|
+
const data = { action: 'bad', category: 'bad' };
|
|
82
|
+
tracking.dispatch('test', 'test', data);
|
|
83
|
+
expect(tracking.dispatchCustomEvent).not.toHaveBeenCalledWith({
|
|
84
|
+
action: 'bad',
|
|
85
|
+
category: 'bad',
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('empty properties', () => {
|
|
91
|
+
const data = {
|
|
92
|
+
testUndefined: undefined,
|
|
93
|
+
testNull: null,
|
|
94
|
+
testEmptyString: '',
|
|
95
|
+
testZero: 0,
|
|
96
|
+
testFalse: false,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
it('does not send undefined properties', () => {
|
|
100
|
+
tracking.dispatch('test', 'test', data);
|
|
101
|
+
expect(tracking.dispatchCustomEvent).toHaveBeenCalledWith(
|
|
102
|
+
expect.not.objectContaining({ testUndefined: undefined })
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('does not send null properties', () => {
|
|
107
|
+
tracking.dispatch('test', 'test', data);
|
|
108
|
+
expect(tracking.dispatchCustomEvent).toHaveBeenCalledWith(
|
|
109
|
+
expect.not.objectContaining({ testNull: null })
|
|
110
|
+
);
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
it('does not send empty string properties', () => {
|
|
114
|
+
tracking.dispatch('test', 'test', data);
|
|
115
|
+
expect(tracking.dispatchCustomEvent).toHaveBeenCalledWith(
|
|
116
|
+
expect.not.objectContaining({ testEmptyString: '' })
|
|
117
|
+
);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('sends zero properties', () => {
|
|
121
|
+
tracking.dispatch('test', 'test', data);
|
|
122
|
+
expect(tracking.dispatchCustomEvent).toHaveBeenCalledWith(
|
|
123
|
+
expect.objectContaining({ testZero: 0 })
|
|
124
|
+
);
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it('sends false properties', () => {
|
|
128
|
+
tracking.dispatch('test', 'test', data);
|
|
129
|
+
|
|
130
|
+
expect(tracking.dispatchCustomEvent).toHaveBeenCalledWith(
|
|
131
|
+
expect.objectContaining({ testFalse: false })
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe('dispatchCustomEvent', () => {
|
|
138
|
+
const eventData = { action: 'test', category: 'test' };
|
|
139
|
+
|
|
140
|
+
it('does not throw an error', () => {
|
|
141
|
+
expect(() => {
|
|
142
|
+
tracking.dispatchCustomEvent(eventData);
|
|
143
|
+
}).not.toThrow();
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
it('passes event data to the CustomEvent detail parameter', () => {
|
|
147
|
+
tracking.dispatchCustomEvent(eventData);
|
|
148
|
+
expect(window.CustomEvent).toHaveBeenCalledWith(
|
|
149
|
+
expect.anything(),
|
|
150
|
+
expect.objectContaining({ detail: eventData })
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('writes debug data', () => {
|
|
155
|
+
tracking.dispatchCustomEvent(eventData);
|
|
156
|
+
expect(tracking.getDebugData()[0].data).toMatchObject(eventData);
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
describe('dispatchImage', () => {
|
|
161
|
+
const eventData = { action: 'test', category: 'test' };
|
|
162
|
+
|
|
163
|
+
it('does not throw an error', () => {
|
|
164
|
+
expect(() => {
|
|
165
|
+
tracking.dispatchImage(eventData);
|
|
166
|
+
}).not.toThrow();
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
it('writes debug data', () => {
|
|
170
|
+
tracking.dispatchImage(eventData);
|
|
171
|
+
expect(tracking.getDebugData()[0].data).toMatchObject(eventData);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
});
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
jest.mock('@financial-times/o-forms');
|
|
2
|
+
jest.mock('@financial-times/o-forms/src/js/input');
|
|
3
|
+
const OForms = require('@financial-times/o-forms');
|
|
4
|
+
const Input = require('@financial-times/o-forms/src/js/input').default;
|
|
5
|
+
const ValidationUtil = require('./validation');
|
|
6
|
+
|
|
7
|
+
describe('Validation - Util', () => {
|
|
8
|
+
let validation;
|
|
9
|
+
beforeEach(() => {
|
|
10
|
+
document.body.innerHTML = `
|
|
11
|
+
<!DOCTYPE html>
|
|
12
|
+
<html>
|
|
13
|
+
<head></head>
|
|
14
|
+
<body>
|
|
15
|
+
<form class="ncf"></form>
|
|
16
|
+
</body>
|
|
17
|
+
</html>`;
|
|
18
|
+
|
|
19
|
+
validation = new ValidationUtil(document);
|
|
20
|
+
jest.spyOn(validation, 'checkFormValidity');
|
|
21
|
+
validation.init();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
afterEach(() => {
|
|
25
|
+
jest.clearAllMocks();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('constructor', () => {
|
|
29
|
+
it('calls oForms to setup client side validation', () => {
|
|
30
|
+
expect(OForms.default.init).toHaveBeenCalled();
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('checks validation status on init', () => {
|
|
34
|
+
expect(validation.checkFormValidity).toHaveBeenCalled();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('has a $form property exposing the form element', () => {
|
|
38
|
+
expect(validation.$form).toBeDefined();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('init', () => {
|
|
43
|
+
it('adds an event listener to required elements', () => {
|
|
44
|
+
expect(
|
|
45
|
+
validation.$requiredEls[0].input.addEventListener
|
|
46
|
+
).toHaveBeenCalled();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('binds to onbeforeunload by default', () => {
|
|
50
|
+
expect(global.window.onbeforeunload).toBeDefined();
|
|
51
|
+
expect(global.window.onbeforeunload).toBeInstanceOf(Function);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('does not bind to onbeforeunload if mutePromptBeforeLeaving = true', () => {
|
|
55
|
+
delete global.window.onbeforeunload;
|
|
56
|
+
const validationTest = new ValidationUtil({
|
|
57
|
+
mutePromptBeforeLeaving: true,
|
|
58
|
+
});
|
|
59
|
+
validationTest.init();
|
|
60
|
+
|
|
61
|
+
expect(global.window.onbeforeunload).not.toBeDefined();
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
describe('onbeforeunload', () => {
|
|
66
|
+
it('returns null by default', () => {
|
|
67
|
+
expect(global.window.onbeforeunload()).toBe(null);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('returns true if the form has changed', () => {
|
|
71
|
+
validation.formChanged = true;
|
|
72
|
+
|
|
73
|
+
expect(global.window.onbeforeunload()).toBe(true);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
describe('checkElementValidity', () => {
|
|
78
|
+
let $el;
|
|
79
|
+
|
|
80
|
+
beforeEach(() => {
|
|
81
|
+
$el = { foo: true };
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('does not call validateInput if custom validation fails', () => {
|
|
85
|
+
jest.spyOn(validation, 'checkCustomValidation').mockReturnValue(false);
|
|
86
|
+
validation.checkElementValidity($el);
|
|
87
|
+
|
|
88
|
+
expect(Input).not.toHaveBeenCalled();
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
it('calls input.validate for the element.', () => {
|
|
92
|
+
validation.checkElementValidity($el);
|
|
93
|
+
|
|
94
|
+
expect(Input).toHaveBeenCalledWith($el);
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
describe('checkFormValidity', () => {
|
|
99
|
+
it('sets the form as invalid if there are invalid elements.', () => {
|
|
100
|
+
validation.formValid = true;
|
|
101
|
+
validation.$requiredEls[0].input.checkValidity.mockReturnValue(false);
|
|
102
|
+
|
|
103
|
+
validation.checkFormValidity();
|
|
104
|
+
|
|
105
|
+
expect(validation.formValid).toBe(false);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('sets the form as valid if there are no invalid elements.', () => {
|
|
109
|
+
validation.formValid = false;
|
|
110
|
+
|
|
111
|
+
validation.checkFormValidity();
|
|
112
|
+
|
|
113
|
+
expect(validation.formValid).toBe(true);
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
describe('Custom Validation', () => {
|
|
118
|
+
let field;
|
|
119
|
+
|
|
120
|
+
beforeEach(() => {
|
|
121
|
+
field = validation.oForms.formInputs.find(
|
|
122
|
+
(el) => el.input.name === 'foo'
|
|
123
|
+
);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
describe('addCustomValidation', () => {
|
|
127
|
+
it('stores a custom validation function', () => {
|
|
128
|
+
validation.addCustomValidation({
|
|
129
|
+
errorMessage: 'Oops, something custom went wrong!',
|
|
130
|
+
field,
|
|
131
|
+
validator: jest.fn(),
|
|
132
|
+
});
|
|
133
|
+
expect(validation.customValidation.size).toBe(1);
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
it('throws if a custom validation function has already been specified for a particular field', () => {
|
|
137
|
+
validation.addCustomValidation({
|
|
138
|
+
errorMessage: 'Oops, something custom went wrong!',
|
|
139
|
+
field,
|
|
140
|
+
validator: jest.fn(),
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
expect(() => {
|
|
144
|
+
validation.addCustomValidation({
|
|
145
|
+
errorMessage: 'Oops, something else custom went wrong!',
|
|
146
|
+
field,
|
|
147
|
+
});
|
|
148
|
+
}).toThrow();
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
it('stores a custom validation function that will show a custom validation message when validation fails', async () => {
|
|
152
|
+
jest.spyOn(validation, 'showCustomFieldValidationError');
|
|
153
|
+
jest.spyOn(validation, 'clearCustomFieldValidationError');
|
|
154
|
+
|
|
155
|
+
validation.addCustomValidation({
|
|
156
|
+
errorMessage: 'Oops, something custom went wrong!',
|
|
157
|
+
field,
|
|
158
|
+
validator: jest.fn().mockReturnValue(false),
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
// Run the stored custom validation function
|
|
162
|
+
await validation.customValidation.get('foo')();
|
|
163
|
+
|
|
164
|
+
expect(validation.showCustomFieldValidationError).toHaveBeenCalled();
|
|
165
|
+
expect(
|
|
166
|
+
validation.clearCustomFieldValidationError
|
|
167
|
+
).not.toHaveBeenCalled();
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
it('stores a custom validation function that will clear a custom validation message when validation passes', async () => {
|
|
171
|
+
jest.spyOn(validation, 'showCustomFieldValidationError');
|
|
172
|
+
jest.spyOn(validation, 'clearCustomFieldValidationError');
|
|
173
|
+
|
|
174
|
+
validation.addCustomValidation({
|
|
175
|
+
errorMessage: 'Oops, something custom went wrong!',
|
|
176
|
+
field,
|
|
177
|
+
validator: jest.fn().mockReturnValue(true),
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
// Run the stored custom validation function
|
|
181
|
+
await validation.customValidation.get('foo')();
|
|
182
|
+
|
|
183
|
+
expect(validation.clearCustomFieldValidationError).toHaveBeenCalled();
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
describe('showCustomFieldValidationError', () => {
|
|
188
|
+
let messageStub = { foo: 'bar' };
|
|
189
|
+
|
|
190
|
+
it('adds the o-form--error class to the parent', () => {
|
|
191
|
+
jest.spyOn(field.input.parentNode.classList, 'add');
|
|
192
|
+
validation.showCustomFieldValidationError(field.input, messageStub);
|
|
193
|
+
|
|
194
|
+
expect(field.input.parentNode.classList.add).toHaveBeenCalledWith(
|
|
195
|
+
'o-forms-input--invalid'
|
|
196
|
+
);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('adds the message to the parent', () => {
|
|
200
|
+
jest.spyOn(global.document, 'querySelector').mockReturnValue(null);
|
|
201
|
+
validation.showCustomFieldValidationError(field.input, messageStub);
|
|
202
|
+
|
|
203
|
+
expect(field.input.parentNode.insertBefore).toHaveBeenCalledWith(
|
|
204
|
+
messageStub,
|
|
205
|
+
null
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
describe('clearCustomFieldValidationError', () => {
|
|
211
|
+
beforeEach(() => {
|
|
212
|
+
validation.$form = document.createElement('form');
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('removes the message from the page', () => {
|
|
216
|
+
jest
|
|
217
|
+
.spyOn(validation.$form, 'querySelector')
|
|
218
|
+
.mockReturnValue(field.input);
|
|
219
|
+
validation.clearCustomFieldValidationError(field.input);
|
|
220
|
+
|
|
221
|
+
expect(field.parentNode.removeChild).toHaveBeenCalledWith(field.input);
|
|
222
|
+
});
|
|
223
|
+
|
|
224
|
+
it('re-checks the element validity for standard validation rules', () => {
|
|
225
|
+
jest.spyOn(validation, 'checkElementValidity');
|
|
226
|
+
validation.clearCustomFieldValidationError(field.input);
|
|
227
|
+
|
|
228
|
+
expect(validation.checkElementValidity).toHaveBeenCalledWith(
|
|
229
|
+
field.input
|
|
230
|
+
);
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
});
|