@instructure/ui-form-field 8.55.1-snapshot-3 → 8.55.1-snapshot-4
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/CHANGELOG.md +1 -1
- package/es/FormField/__new-tests__/FormField.test.js +58 -0
- package/es/FormFieldGroup/__new-tests__/FormFieldGroup.test.js +95 -0
- package/es/FormFieldLabel/__new-tests__/FormFieldLabel.test.js +54 -0
- package/es/FormFieldLayout/__new-tests__/FormFieldLayout.test.js +62 -0
- package/es/FormFieldMessage/__new-tests__/FormFieldMessage.test.js +55 -0
- package/es/FormFieldMessages/__new-tests__/FormFieldMessages.test.js +85 -0
- package/lib/FormField/__new-tests__/FormField.test.js +60 -0
- package/lib/FormFieldGroup/__new-tests__/FormFieldGroup.test.js +97 -0
- package/lib/FormFieldLabel/__new-tests__/FormFieldLabel.test.js +56 -0
- package/lib/FormFieldLayout/__new-tests__/FormFieldLayout.test.js +64 -0
- package/lib/FormFieldMessage/__new-tests__/FormFieldMessage.test.js +57 -0
- package/lib/FormFieldMessages/__new-tests__/FormFieldMessages.test.js +87 -0
- package/package.json +17 -14
- package/src/FormField/__new-tests__/FormField.test.tsx +54 -0
- package/src/FormFieldGroup/__new-tests__/FormFieldGroup.test.tsx +164 -0
- package/src/FormFieldLabel/__new-tests__/FormFieldLabel.test.tsx +60 -0
- package/src/FormFieldLayout/__new-tests__/FormFieldLayout.test.tsx +69 -0
- package/src/FormFieldMessage/__new-tests__/FormFieldMessage.test.tsx +73 -0
- package/src/FormFieldMessages/__new-tests__/FormFieldMessages.test.tsx +91 -0
- package/tsconfig.build.json +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/FormField/__new-tests__/FormField.test.d.ts +2 -0
- package/types/FormField/__new-tests__/FormField.test.d.ts.map +1 -0
- package/types/FormFieldGroup/__new-tests__/FormFieldGroup.test.d.ts +2 -0
- package/types/FormFieldGroup/__new-tests__/FormFieldGroup.test.d.ts.map +1 -0
- package/types/FormFieldLabel/__new-tests__/FormFieldLabel.test.d.ts +2 -0
- package/types/FormFieldLabel/__new-tests__/FormFieldLabel.test.d.ts.map +1 -0
- package/types/FormFieldLayout/__new-tests__/FormFieldLayout.test.d.ts +2 -0
- package/types/FormFieldLayout/__new-tests__/FormFieldLayout.test.d.ts.map +1 -0
- package/types/FormFieldMessage/__new-tests__/FormFieldMessage.test.d.ts +2 -0
- package/types/FormFieldMessage/__new-tests__/FormFieldMessage.test.d.ts.map +1 -0
- package/types/FormFieldMessages/__new-tests__/FormFieldMessages.test.d.ts +2 -0
- package/types/FormFieldMessages/__new-tests__/FormFieldMessages.test.d.ts.map +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
## [8.55.1-snapshot-
|
|
6
|
+
## [8.55.1-snapshot-4](https://github.com/instructure/instructure-ui/compare/v8.55.0...v8.55.1-snapshot-4) (2024-04-17)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-form-field
|
|
9
9
|
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var _FormField, _FormField2, _FormField3;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render, screen } from '@testing-library/react';
|
|
28
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
|
+
import '@testing-library/jest-dom';
|
|
30
|
+
import { FormField } from '../index';
|
|
31
|
+
describe('<FormField />', () => {
|
|
32
|
+
it('should render', () => {
|
|
33
|
+
render(_FormField || (_FormField = /*#__PURE__*/React.createElement(FormField, {
|
|
34
|
+
label: "foo",
|
|
35
|
+
id: "bar"
|
|
36
|
+
})));
|
|
37
|
+
const formField = screen.getByText('foo').closest('label');
|
|
38
|
+
expect(formField).toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
it('passes props through to FormField', () => {
|
|
41
|
+
render(_FormField2 || (_FormField2 = /*#__PURE__*/React.createElement(FormField, {
|
|
42
|
+
label: "foo",
|
|
43
|
+
id: "bar",
|
|
44
|
+
"data-automation": "baz"
|
|
45
|
+
})));
|
|
46
|
+
const formField = screen.getByText('foo').closest('label');
|
|
47
|
+
expect(formField).toHaveAttribute('data-automation', 'baz');
|
|
48
|
+
});
|
|
49
|
+
it('should meet a11y standards', async () => {
|
|
50
|
+
const _render = render(_FormField3 || (_FormField3 = /*#__PURE__*/React.createElement(FormField, {
|
|
51
|
+
label: "foo",
|
|
52
|
+
id: "bar"
|
|
53
|
+
}))),
|
|
54
|
+
container = _render.container;
|
|
55
|
+
const axeCheck = await runAxeCheck(container);
|
|
56
|
+
expect(axeCheck).toBe(true);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var _FormFieldGroup, _label, _label2, _label3, _label4, _label5, _label6, _label7, _FormFieldGroup2;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render, screen } from '@testing-library/react';
|
|
28
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
|
+
import '@testing-library/jest-dom';
|
|
30
|
+
import { FormFieldGroup } from '../index';
|
|
31
|
+
describe('<FormFieldGroup />', () => {
|
|
32
|
+
it('should render', () => {
|
|
33
|
+
const _render = render(_FormFieldGroup || (_FormFieldGroup = /*#__PURE__*/React.createElement(FormFieldGroup, {
|
|
34
|
+
description: "Please enter your full name"
|
|
35
|
+
}, /*#__PURE__*/React.createElement("label", null, "First: ", /*#__PURE__*/React.createElement("input", null)), /*#__PURE__*/React.createElement("label", null, "Middle: ", /*#__PURE__*/React.createElement("input", null)), /*#__PURE__*/React.createElement("label", null, "Last: ", /*#__PURE__*/React.createElement("input", null))))),
|
|
36
|
+
container = _render.container;
|
|
37
|
+
const formFieldGroup = container.querySelector("fieldset[class$='-formFieldLayout']");
|
|
38
|
+
const firstNameInput = screen.getByLabelText('First:');
|
|
39
|
+
const middleNameInput = screen.getByLabelText('Middle:');
|
|
40
|
+
const lastNameInput = screen.getByLabelText('Last:');
|
|
41
|
+
expect(formFieldGroup).toBeInTheDocument();
|
|
42
|
+
expect(formFieldGroup).toHaveTextContent('Please enter your full name');
|
|
43
|
+
expect(firstNameInput).toBeInTheDocument();
|
|
44
|
+
expect(middleNameInput).toBeInTheDocument();
|
|
45
|
+
expect(lastNameInput).toBeInTheDocument();
|
|
46
|
+
});
|
|
47
|
+
it('can handle null children', () => {
|
|
48
|
+
const children = [_label || (_label = /*#__PURE__*/React.createElement("label", {
|
|
49
|
+
key: "first"
|
|
50
|
+
}, "First: ", /*#__PURE__*/React.createElement("input", null))), null];
|
|
51
|
+
const _render2 = render( /*#__PURE__*/React.createElement(FormFieldGroup, {
|
|
52
|
+
description: "Please enter your full name"
|
|
53
|
+
}, children)),
|
|
54
|
+
container = _render2.container;
|
|
55
|
+
const formFieldGroup = container.querySelector("fieldset[class$='-formFieldLayout']");
|
|
56
|
+
expect(formFieldGroup).toBeInTheDocument();
|
|
57
|
+
});
|
|
58
|
+
it('links the messages to the fieldset via aria-describedby', () => {
|
|
59
|
+
const messages = [{
|
|
60
|
+
text: 'Invalid name',
|
|
61
|
+
type: 'error'
|
|
62
|
+
}];
|
|
63
|
+
const _render3 = render( /*#__PURE__*/React.createElement(FormFieldGroup, {
|
|
64
|
+
description: "Please enter your full name",
|
|
65
|
+
messages: messages
|
|
66
|
+
}, _label2 || (_label2 = /*#__PURE__*/React.createElement("label", null, "First: ", /*#__PURE__*/React.createElement("input", null))), _label3 || (_label3 = /*#__PURE__*/React.createElement("label", null, "Middle: ", /*#__PURE__*/React.createElement("input", null))), _label4 || (_label4 = /*#__PURE__*/React.createElement("label", null, "Last: ", /*#__PURE__*/React.createElement("input", null))))),
|
|
67
|
+
container = _render3.container;
|
|
68
|
+
const formFieldGroup = container.querySelector("fieldset[class$='-formFieldLayout']");
|
|
69
|
+
const message = container.querySelector("span[id^='FormFieldLayout_']");
|
|
70
|
+
expect(message).toBeInTheDocument();
|
|
71
|
+
expect(formFieldGroup).toBeInTheDocument();
|
|
72
|
+
expect(formFieldGroup).toHaveAttribute('aria-describedby');
|
|
73
|
+
const messagesId = formFieldGroup.getAttribute('aria-describedby');
|
|
74
|
+
expect(message).toHaveTextContent('Invalid name');
|
|
75
|
+
expect(message).toHaveAttribute('id', messagesId);
|
|
76
|
+
});
|
|
77
|
+
it('displays description message inside the legend', () => {
|
|
78
|
+
const description = 'Please enter your full name';
|
|
79
|
+
const _render4 = render( /*#__PURE__*/React.createElement(FormFieldGroup, {
|
|
80
|
+
description: description
|
|
81
|
+
}, _label5 || (_label5 = /*#__PURE__*/React.createElement("label", null, "First: ", /*#__PURE__*/React.createElement("input", null))), _label6 || (_label6 = /*#__PURE__*/React.createElement("label", null, "Middle: ", /*#__PURE__*/React.createElement("input", null))), _label7 || (_label7 = /*#__PURE__*/React.createElement("label", null, "Last: ", /*#__PURE__*/React.createElement("input", null))))),
|
|
82
|
+
container = _render4.container;
|
|
83
|
+
const legend = container.querySelector("legend[class$='-screenReaderContent']");
|
|
84
|
+
expect(legend).toBeInTheDocument();
|
|
85
|
+
expect(legend).toHaveTextContent(description);
|
|
86
|
+
});
|
|
87
|
+
it('should meet a11y standards', async () => {
|
|
88
|
+
const _render5 = render(_FormFieldGroup2 || (_FormFieldGroup2 = /*#__PURE__*/React.createElement(FormFieldGroup, {
|
|
89
|
+
description: "Please enter your full name"
|
|
90
|
+
}, /*#__PURE__*/React.createElement("label", null, "First: ", /*#__PURE__*/React.createElement("input", null)), /*#__PURE__*/React.createElement("label", null, "Middle: ", /*#__PURE__*/React.createElement("input", null)), /*#__PURE__*/React.createElement("label", null, "Last: ", /*#__PURE__*/React.createElement("input", null))))),
|
|
91
|
+
container = _render5.container;
|
|
92
|
+
const axeCheck = await runAxeCheck(container);
|
|
93
|
+
expect(axeCheck).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var _FormFieldLabel, _FormFieldLabel2, _FormFieldLabel3;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render } from '@testing-library/react';
|
|
28
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
|
+
import '@testing-library/jest-dom';
|
|
30
|
+
import { FormFieldLabel } from '../index';
|
|
31
|
+
describe('<FormFieldLabel />', () => {
|
|
32
|
+
it('should render', () => {
|
|
33
|
+
const _render = render(_FormFieldLabel || (_FormFieldLabel = /*#__PURE__*/React.createElement(FormFieldLabel, null, "Foo"))),
|
|
34
|
+
container = _render.container;
|
|
35
|
+
const formFieldLabel = container.querySelector("span[class$='-formFieldLabel']");
|
|
36
|
+
expect(formFieldLabel).toBeInTheDocument();
|
|
37
|
+
expect(formFieldLabel).toHaveTextContent('Foo');
|
|
38
|
+
});
|
|
39
|
+
it('should render as specified via the `as` prop', () => {
|
|
40
|
+
const _render2 = render(_FormFieldLabel2 || (_FormFieldLabel2 = /*#__PURE__*/React.createElement(FormFieldLabel, {
|
|
41
|
+
as: "li"
|
|
42
|
+
}, "Foo"))),
|
|
43
|
+
container = _render2.container;
|
|
44
|
+
const formFieldLabel = container.querySelector('li');
|
|
45
|
+
expect(formFieldLabel).toBeInTheDocument();
|
|
46
|
+
expect(formFieldLabel).toHaveTextContent('Foo');
|
|
47
|
+
});
|
|
48
|
+
it('should meet a11y standards', async () => {
|
|
49
|
+
const _render3 = render(_FormFieldLabel3 || (_FormFieldLabel3 = /*#__PURE__*/React.createElement(FormFieldLabel, null, "Foo"))),
|
|
50
|
+
container = _render3.container;
|
|
51
|
+
const axeCheck = await runAxeCheck(container);
|
|
52
|
+
expect(axeCheck).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var _FormFieldLayout, _FormFieldLayout2, _input;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render, screen } from '@testing-library/react';
|
|
28
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
|
+
import '@testing-library/jest-dom';
|
|
30
|
+
import { FormFieldLayout } from '../index';
|
|
31
|
+
describe('<FormFieldLayout />', () => {
|
|
32
|
+
it('should render', () => {
|
|
33
|
+
const _render = render(_FormFieldLayout || (_FormFieldLayout = /*#__PURE__*/React.createElement(FormFieldLayout, {
|
|
34
|
+
label: "Username"
|
|
35
|
+
}))),
|
|
36
|
+
container = _render.container;
|
|
37
|
+
const formFieldLayout = container.querySelector("label[class$='-formFieldLayout']");
|
|
38
|
+
const formFieldLabel = container.querySelector("span[class$='-formFieldLabel']");
|
|
39
|
+
expect(formFieldLayout).toBeInTheDocument();
|
|
40
|
+
expect(formFieldLabel).toBeInTheDocument();
|
|
41
|
+
expect(formFieldLabel).toHaveTextContent('Username');
|
|
42
|
+
});
|
|
43
|
+
it('should meet a11y standards', async () => {
|
|
44
|
+
const _render2 = render(_FormFieldLayout2 || (_FormFieldLayout2 = /*#__PURE__*/React.createElement(FormFieldLayout, {
|
|
45
|
+
label: "Username"
|
|
46
|
+
}))),
|
|
47
|
+
container = _render2.container;
|
|
48
|
+
const axeCheck = await runAxeCheck(container);
|
|
49
|
+
expect(axeCheck).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
it('should provide a ref to the input container', () => {
|
|
52
|
+
const inputContainerRef = jest.fn();
|
|
53
|
+
render( /*#__PURE__*/React.createElement(FormFieldLayout, {
|
|
54
|
+
label: "Username",
|
|
55
|
+
inputContainerRef: inputContainerRef
|
|
56
|
+
}, _input || (_input = /*#__PURE__*/React.createElement("input", {
|
|
57
|
+
type: "text"
|
|
58
|
+
}))));
|
|
59
|
+
const input = screen.getByLabelText('Username');
|
|
60
|
+
expect(inputContainerRef).toHaveBeenCalledWith(input.parentElement);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var _FormFieldMessage, _FormFieldMessage2, _FormFieldMessage3;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render } from '@testing-library/react';
|
|
28
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
|
+
import { IconWarningLine } from '@instructure/ui-icons';
|
|
30
|
+
import '@testing-library/jest-dom';
|
|
31
|
+
import { FormFieldMessage } from '../index';
|
|
32
|
+
describe('<FormFieldMessage />', () => {
|
|
33
|
+
it('should render message', () => {
|
|
34
|
+
const _render = render(_FormFieldMessage || (_FormFieldMessage = /*#__PURE__*/React.createElement(FormFieldMessage, null, "hello world"))),
|
|
35
|
+
container = _render.container;
|
|
36
|
+
const formFieldMessage = container.querySelector("span[class$='-formFieldMessage']");
|
|
37
|
+
expect(formFieldMessage).toBeInTheDocument();
|
|
38
|
+
expect(formFieldMessage).toHaveTextContent('hello world');
|
|
39
|
+
});
|
|
40
|
+
it('should render message if Node is passed', () => {
|
|
41
|
+
const _render2 = render(_FormFieldMessage2 || (_FormFieldMessage2 = /*#__PURE__*/React.createElement(FormFieldMessage, null, /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(IconWarningLine, null), " Invalid name")))),
|
|
42
|
+
container = _render2.container;
|
|
43
|
+
const formFieldMessage = container.querySelector("span[class$='-formFieldMessage']");
|
|
44
|
+
const iconSvg = container.querySelector('svg[name="IconWarning"]');
|
|
45
|
+
expect(iconSvg).toBeInTheDocument();
|
|
46
|
+
expect(formFieldMessage).toBeInTheDocument();
|
|
47
|
+
expect(formFieldMessage).toHaveTextContent('Invalid name');
|
|
48
|
+
});
|
|
49
|
+
it('should meet a11y standards', async () => {
|
|
50
|
+
const _render3 = render(_FormFieldMessage3 || (_FormFieldMessage3 = /*#__PURE__*/React.createElement(FormFieldMessage, null))),
|
|
51
|
+
container = _render3.container;
|
|
52
|
+
const axeCheck = await runAxeCheck(container);
|
|
53
|
+
expect(axeCheck).toBe(true);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
var _span;
|
|
2
|
+
/*
|
|
3
|
+
* The MIT License (MIT)
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import React from 'react';
|
|
27
|
+
import { render } from '@testing-library/react';
|
|
28
|
+
import { runAxeCheck } from '@instructure/ui-axe-check';
|
|
29
|
+
import { IconWarningLine } from '@instructure/ui-icons';
|
|
30
|
+
import '@testing-library/jest-dom';
|
|
31
|
+
import { FormFieldMessages } from '../index';
|
|
32
|
+
describe('<FormFieldMessages />', () => {
|
|
33
|
+
it('should render', () => {
|
|
34
|
+
const messages = [{
|
|
35
|
+
text: 'Invalid name',
|
|
36
|
+
type: 'error'
|
|
37
|
+
}, {
|
|
38
|
+
text: 'Good job!',
|
|
39
|
+
type: 'success'
|
|
40
|
+
}, {
|
|
41
|
+
text: 'Full name, first and last',
|
|
42
|
+
type: 'hint'
|
|
43
|
+
}];
|
|
44
|
+
const _render = render( /*#__PURE__*/React.createElement(FormFieldMessages, {
|
|
45
|
+
messages: messages
|
|
46
|
+
})),
|
|
47
|
+
container = _render.container;
|
|
48
|
+
const formFieldMessages = container.querySelector("span[class$='-formFieldMessages']");
|
|
49
|
+
expect(formFieldMessages).toBeInTheDocument();
|
|
50
|
+
expect(formFieldMessages).toHaveTextContent('Invalid nameGood job!Full name, first and last');
|
|
51
|
+
});
|
|
52
|
+
it('should render if Node is passed as message text', () => {
|
|
53
|
+
const messages = [{
|
|
54
|
+
text: _span || (_span = /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(IconWarningLine, null), " Invalid name")),
|
|
55
|
+
type: 'error'
|
|
56
|
+
}];
|
|
57
|
+
const _render2 = render( /*#__PURE__*/React.createElement(FormFieldMessages, {
|
|
58
|
+
messages: messages
|
|
59
|
+
})),
|
|
60
|
+
container = _render2.container;
|
|
61
|
+
const formFieldMessages = container.querySelector("span[class$='-formFieldMessages']");
|
|
62
|
+
const iconSvg = container.querySelector('svg[name="IconWarning"]');
|
|
63
|
+
expect(iconSvg).toBeInTheDocument();
|
|
64
|
+
expect(formFieldMessages).toBeInTheDocument();
|
|
65
|
+
expect(formFieldMessages).toHaveTextContent('Invalid name');
|
|
66
|
+
});
|
|
67
|
+
it('should meet a11y standards', async () => {
|
|
68
|
+
const messages = [{
|
|
69
|
+
text: 'Invalid name',
|
|
70
|
+
type: 'error'
|
|
71
|
+
}, {
|
|
72
|
+
text: 'Good job!',
|
|
73
|
+
type: 'success'
|
|
74
|
+
}, {
|
|
75
|
+
text: 'Full name, first and last',
|
|
76
|
+
type: 'hint'
|
|
77
|
+
}];
|
|
78
|
+
const _render3 = render( /*#__PURE__*/React.createElement(FormFieldMessages, {
|
|
79
|
+
messages: messages
|
|
80
|
+
})),
|
|
81
|
+
container = _render3.container;
|
|
82
|
+
const axeCheck = await runAxeCheck(container);
|
|
83
|
+
expect(axeCheck).toBe(true);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
var _index = require("../index");
|
|
9
|
+
var _FormField, _FormField2, _FormField3;
|
|
10
|
+
/*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
describe('<FormField />', () => {
|
|
34
|
+
it('should render', () => {
|
|
35
|
+
(0, _react2.render)(_FormField || (_FormField = /*#__PURE__*/_react.default.createElement(_index.FormField, {
|
|
36
|
+
label: "foo",
|
|
37
|
+
id: "bar"
|
|
38
|
+
})));
|
|
39
|
+
const formField = _react2.screen.getByText('foo').closest('label');
|
|
40
|
+
expect(formField).toBeInTheDocument();
|
|
41
|
+
});
|
|
42
|
+
it('passes props through to FormField', () => {
|
|
43
|
+
(0, _react2.render)(_FormField2 || (_FormField2 = /*#__PURE__*/_react.default.createElement(_index.FormField, {
|
|
44
|
+
label: "foo",
|
|
45
|
+
id: "bar",
|
|
46
|
+
"data-automation": "baz"
|
|
47
|
+
})));
|
|
48
|
+
const formField = _react2.screen.getByText('foo').closest('label');
|
|
49
|
+
expect(formField).toHaveAttribute('data-automation', 'baz');
|
|
50
|
+
});
|
|
51
|
+
it('should meet a11y standards', async () => {
|
|
52
|
+
const _render = (0, _react2.render)(_FormField3 || (_FormField3 = /*#__PURE__*/_react.default.createElement(_index.FormField, {
|
|
53
|
+
label: "foo",
|
|
54
|
+
id: "bar"
|
|
55
|
+
}))),
|
|
56
|
+
container = _render.container;
|
|
57
|
+
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
58
|
+
expect(axeCheck).toBe(true);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
var _index = require("../index");
|
|
9
|
+
var _FormFieldGroup, _label, _label2, _label3, _label4, _label5, _label6, _label7, _FormFieldGroup2;
|
|
10
|
+
/*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
describe('<FormFieldGroup />', () => {
|
|
34
|
+
it('should render', () => {
|
|
35
|
+
const _render = (0, _react2.render)(_FormFieldGroup || (_FormFieldGroup = /*#__PURE__*/_react.default.createElement(_index.FormFieldGroup, {
|
|
36
|
+
description: "Please enter your full name"
|
|
37
|
+
}, /*#__PURE__*/_react.default.createElement("label", null, "First: ", /*#__PURE__*/_react.default.createElement("input", null)), /*#__PURE__*/_react.default.createElement("label", null, "Middle: ", /*#__PURE__*/_react.default.createElement("input", null)), /*#__PURE__*/_react.default.createElement("label", null, "Last: ", /*#__PURE__*/_react.default.createElement("input", null))))),
|
|
38
|
+
container = _render.container;
|
|
39
|
+
const formFieldGroup = container.querySelector("fieldset[class$='-formFieldLayout']");
|
|
40
|
+
const firstNameInput = _react2.screen.getByLabelText('First:');
|
|
41
|
+
const middleNameInput = _react2.screen.getByLabelText('Middle:');
|
|
42
|
+
const lastNameInput = _react2.screen.getByLabelText('Last:');
|
|
43
|
+
expect(formFieldGroup).toBeInTheDocument();
|
|
44
|
+
expect(formFieldGroup).toHaveTextContent('Please enter your full name');
|
|
45
|
+
expect(firstNameInput).toBeInTheDocument();
|
|
46
|
+
expect(middleNameInput).toBeInTheDocument();
|
|
47
|
+
expect(lastNameInput).toBeInTheDocument();
|
|
48
|
+
});
|
|
49
|
+
it('can handle null children', () => {
|
|
50
|
+
const children = [_label || (_label = /*#__PURE__*/_react.default.createElement("label", {
|
|
51
|
+
key: "first"
|
|
52
|
+
}, "First: ", /*#__PURE__*/_react.default.createElement("input", null))), null];
|
|
53
|
+
const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.FormFieldGroup, {
|
|
54
|
+
description: "Please enter your full name"
|
|
55
|
+
}, children)),
|
|
56
|
+
container = _render2.container;
|
|
57
|
+
const formFieldGroup = container.querySelector("fieldset[class$='-formFieldLayout']");
|
|
58
|
+
expect(formFieldGroup).toBeInTheDocument();
|
|
59
|
+
});
|
|
60
|
+
it('links the messages to the fieldset via aria-describedby', () => {
|
|
61
|
+
const messages = [{
|
|
62
|
+
text: 'Invalid name',
|
|
63
|
+
type: 'error'
|
|
64
|
+
}];
|
|
65
|
+
const _render3 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.FormFieldGroup, {
|
|
66
|
+
description: "Please enter your full name",
|
|
67
|
+
messages: messages
|
|
68
|
+
}, _label2 || (_label2 = /*#__PURE__*/_react.default.createElement("label", null, "First: ", /*#__PURE__*/_react.default.createElement("input", null))), _label3 || (_label3 = /*#__PURE__*/_react.default.createElement("label", null, "Middle: ", /*#__PURE__*/_react.default.createElement("input", null))), _label4 || (_label4 = /*#__PURE__*/_react.default.createElement("label", null, "Last: ", /*#__PURE__*/_react.default.createElement("input", null))))),
|
|
69
|
+
container = _render3.container;
|
|
70
|
+
const formFieldGroup = container.querySelector("fieldset[class$='-formFieldLayout']");
|
|
71
|
+
const message = container.querySelector("span[id^='FormFieldLayout_']");
|
|
72
|
+
expect(message).toBeInTheDocument();
|
|
73
|
+
expect(formFieldGroup).toBeInTheDocument();
|
|
74
|
+
expect(formFieldGroup).toHaveAttribute('aria-describedby');
|
|
75
|
+
const messagesId = formFieldGroup.getAttribute('aria-describedby');
|
|
76
|
+
expect(message).toHaveTextContent('Invalid name');
|
|
77
|
+
expect(message).toHaveAttribute('id', messagesId);
|
|
78
|
+
});
|
|
79
|
+
it('displays description message inside the legend', () => {
|
|
80
|
+
const description = 'Please enter your full name';
|
|
81
|
+
const _render4 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.FormFieldGroup, {
|
|
82
|
+
description: description
|
|
83
|
+
}, _label5 || (_label5 = /*#__PURE__*/_react.default.createElement("label", null, "First: ", /*#__PURE__*/_react.default.createElement("input", null))), _label6 || (_label6 = /*#__PURE__*/_react.default.createElement("label", null, "Middle: ", /*#__PURE__*/_react.default.createElement("input", null))), _label7 || (_label7 = /*#__PURE__*/_react.default.createElement("label", null, "Last: ", /*#__PURE__*/_react.default.createElement("input", null))))),
|
|
84
|
+
container = _render4.container;
|
|
85
|
+
const legend = container.querySelector("legend[class$='-screenReaderContent']");
|
|
86
|
+
expect(legend).toBeInTheDocument();
|
|
87
|
+
expect(legend).toHaveTextContent(description);
|
|
88
|
+
});
|
|
89
|
+
it('should meet a11y standards', async () => {
|
|
90
|
+
const _render5 = (0, _react2.render)(_FormFieldGroup2 || (_FormFieldGroup2 = /*#__PURE__*/_react.default.createElement(_index.FormFieldGroup, {
|
|
91
|
+
description: "Please enter your full name"
|
|
92
|
+
}, /*#__PURE__*/_react.default.createElement("label", null, "First: ", /*#__PURE__*/_react.default.createElement("input", null)), /*#__PURE__*/_react.default.createElement("label", null, "Middle: ", /*#__PURE__*/_react.default.createElement("input", null)), /*#__PURE__*/_react.default.createElement("label", null, "Last: ", /*#__PURE__*/_react.default.createElement("input", null))))),
|
|
93
|
+
container = _render5.container;
|
|
94
|
+
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
95
|
+
expect(axeCheck).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
});
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _react = _interopRequireDefault(require("react"));
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
var _index = require("../index");
|
|
9
|
+
var _FormFieldLabel, _FormFieldLabel2, _FormFieldLabel3;
|
|
10
|
+
/*
|
|
11
|
+
* The MIT License (MIT)
|
|
12
|
+
*
|
|
13
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
14
|
+
*
|
|
15
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
16
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
17
|
+
* in the Software without restriction, including without limitation the rights
|
|
18
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
19
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
20
|
+
* furnished to do so, subject to the following conditions:
|
|
21
|
+
*
|
|
22
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
23
|
+
* copies or substantial portions of the Software.
|
|
24
|
+
*
|
|
25
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
26
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
27
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
28
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
29
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
31
|
+
* SOFTWARE.
|
|
32
|
+
*/
|
|
33
|
+
describe('<FormFieldLabel />', () => {
|
|
34
|
+
it('should render', () => {
|
|
35
|
+
const _render = (0, _react2.render)(_FormFieldLabel || (_FormFieldLabel = /*#__PURE__*/_react.default.createElement(_index.FormFieldLabel, null, "Foo"))),
|
|
36
|
+
container = _render.container;
|
|
37
|
+
const formFieldLabel = container.querySelector("span[class$='-formFieldLabel']");
|
|
38
|
+
expect(formFieldLabel).toBeInTheDocument();
|
|
39
|
+
expect(formFieldLabel).toHaveTextContent('Foo');
|
|
40
|
+
});
|
|
41
|
+
it('should render as specified via the `as` prop', () => {
|
|
42
|
+
const _render2 = (0, _react2.render)(_FormFieldLabel2 || (_FormFieldLabel2 = /*#__PURE__*/_react.default.createElement(_index.FormFieldLabel, {
|
|
43
|
+
as: "li"
|
|
44
|
+
}, "Foo"))),
|
|
45
|
+
container = _render2.container;
|
|
46
|
+
const formFieldLabel = container.querySelector('li');
|
|
47
|
+
expect(formFieldLabel).toBeInTheDocument();
|
|
48
|
+
expect(formFieldLabel).toHaveTextContent('Foo');
|
|
49
|
+
});
|
|
50
|
+
it('should meet a11y standards', async () => {
|
|
51
|
+
const _render3 = (0, _react2.render)(_FormFieldLabel3 || (_FormFieldLabel3 = /*#__PURE__*/_react.default.createElement(_index.FormFieldLabel, null, "Foo"))),
|
|
52
|
+
container = _render3.container;
|
|
53
|
+
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
54
|
+
expect(axeCheck).toBe(true);
|
|
55
|
+
});
|
|
56
|
+
});
|