@instructure/ui-list 10.0.1-snapshot-5 → 10.0.1-snapshot-7

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 (50) hide show
  1. package/CHANGELOG.md +1 -1
  2. package/es/InlineList/InlineListItem/__new-tests__/InlineListItem.test.js +53 -0
  3. package/es/InlineList/__new-tests__/InlineList.test.js +81 -0
  4. package/es/{InlineList/InlineListItem/InlineListItemLocator.js → List/ListItem/__new-tests__/ListItem.test.js} +20 -8
  5. package/es/List/__new-tests__/List.test.js +70 -0
  6. package/lib/InlineList/InlineListItem/__new-tests__/InlineListItem.test.js +55 -0
  7. package/lib/InlineList/__new-tests__/InlineList.test.js +83 -0
  8. package/lib/{InlineList/InlineListItem/InlineListItemLocator.js → List/ListItem/__new-tests__/ListItem.test.js} +21 -13
  9. package/lib/List/__new-tests__/List.test.js +72 -0
  10. package/package.json +16 -13
  11. package/src/InlineList/{InlineListLocator.ts → InlineListItem/__new-tests__/InlineListItem.test.tsx} +28 -11
  12. package/src/InlineList/__new-tests__/InlineList.test.tsx +128 -0
  13. package/src/List/{ListLocator.ts → ListItem/__new-tests__/ListItem.test.tsx} +18 -12
  14. package/src/List/__new-tests__/List.test.tsx +109 -0
  15. package/tsconfig.build.json +1 -1
  16. package/tsconfig.build.tsbuildinfo +1 -1
  17. package/types/InlineList/InlineListItem/__new-tests__/InlineListItem.test.d.ts +2 -0
  18. package/types/InlineList/InlineListItem/__new-tests__/InlineListItem.test.d.ts.map +1 -0
  19. package/types/InlineList/__new-tests__/InlineList.test.d.ts +2 -0
  20. package/types/InlineList/__new-tests__/InlineList.test.d.ts.map +1 -0
  21. package/types/List/ListItem/__new-tests__/ListItem.test.d.ts +2 -0
  22. package/types/List/ListItem/__new-tests__/ListItem.test.d.ts.map +1 -0
  23. package/types/List/__new-tests__/List.test.d.ts +2 -0
  24. package/types/List/__new-tests__/List.test.d.ts.map +1 -0
  25. package/es/InlineList/InlineListItem/locator.js +0 -26
  26. package/es/InlineList/InlineListLocator.js +0 -36
  27. package/es/InlineList/locator.js +0 -26
  28. package/es/List/ListLocator.js +0 -39
  29. package/es/List/locator.js +0 -27
  30. package/lib/InlineList/InlineListItem/locator.js +0 -37
  31. package/lib/InlineList/InlineListLocator.js +0 -42
  32. package/lib/InlineList/locator.js +0 -37
  33. package/lib/List/ListLocator.js +0 -44
  34. package/lib/List/locator.js +0 -37
  35. package/src/InlineList/InlineListItem/InlineListItemLocator.ts +0 -34
  36. package/src/InlineList/InlineListItem/locator.ts +0 -27
  37. package/src/InlineList/locator.ts +0 -27
  38. package/src/List/locator.ts +0 -28
  39. package/types/InlineList/InlineListItem/InlineListItemLocator.d.ts +0 -438
  40. package/types/InlineList/InlineListItem/InlineListItemLocator.d.ts.map +0 -1
  41. package/types/InlineList/InlineListItem/locator.d.ts +0 -4
  42. package/types/InlineList/InlineListItem/locator.d.ts.map +0 -1
  43. package/types/InlineList/InlineListLocator.d.ts +0 -1843
  44. package/types/InlineList/InlineListLocator.d.ts.map +0 -1
  45. package/types/InlineList/locator.d.ts +0 -4
  46. package/types/InlineList/locator.d.ts.map +0 -1
  47. package/types/List/ListLocator.d.ts +0 -1823
  48. package/types/List/ListLocator.d.ts.map +0 -1
  49. package/types/List/locator.d.ts +0 -4
  50. package/types/List/locator.d.ts.map +0 -1
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
- ## [10.0.1-snapshot-5](https://github.com/instructure/instructure-ui/compare/v10.0.0...v10.0.1-snapshot-5) (2024-08-05)
6
+ ## [10.0.1-snapshot-7](https://github.com/instructure/instructure-ui/compare/v10.0.0...v10.0.1-snapshot-7) (2024-08-09)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-list
9
9
 
@@ -0,0 +1,53 @@
1
+ var _InlineListItem, _InlineListItem2;
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 '@testing-library/jest-dom';
28
+ import { render, screen } from '@testing-library/react';
29
+ import { vi } from 'vitest';
30
+ import { InlineListItem } from '../index';
31
+ describe('<InlineListItem />', () => {
32
+ it('should render children', async () => {
33
+ render(_InlineListItem || (_InlineListItem = /*#__PURE__*/React.createElement(InlineListItem, null, "hello")));
34
+ const listItem = screen.getByRole('listitem');
35
+ expect(listItem).toHaveTextContent('hello');
36
+ });
37
+ it('should render delimiter', async () => {
38
+ const _render = render(_InlineListItem2 || (_InlineListItem2 = /*#__PURE__*/React.createElement(InlineListItem, {
39
+ delimiter: "slash"
40
+ }, "List item"))),
41
+ container = _render.container;
42
+ const listItem = container.querySelector('span[class$="delimiter"]');
43
+ expect(listItem).toHaveAttribute('aria-hidden', 'true');
44
+ });
45
+ it('should call elementRef', async () => {
46
+ const elementRef = vi.fn();
47
+ render( /*#__PURE__*/React.createElement(InlineListItem, {
48
+ elementRef: elementRef
49
+ }, "List item"));
50
+ const listItem = screen.getByRole('listitem');
51
+ expect(elementRef).toHaveBeenCalledWith(listItem);
52
+ });
53
+ });
@@ -0,0 +1,81 @@
1
+ var _InlineList$Item, _InlineList$Item2, _InlineList$Item3, _InlineList$Item4, _InlineList$Item5, _InlineList$Item6, _InlineList, _InlineList2, _InlineList3, _InlineList4;
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 '@testing-library/jest-dom';
28
+ import { render, screen } from '@testing-library/react';
29
+ import { vi } from 'vitest';
30
+ import { InlineList } from '../index';
31
+ import { runAxeCheck } from '@instructure/ui-axe-check';
32
+ describe('<InlineList />', () => {
33
+ let consoleWarningMock;
34
+ let consoleErrorMock;
35
+ beforeEach(() => {
36
+ // Mocking console to prevent test output pollution and expect for messages
37
+ consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
38
+ consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
39
+ });
40
+ afterEach(() => {
41
+ consoleWarningMock.mockRestore();
42
+ consoleErrorMock.mockRestore();
43
+ });
44
+ it('should render list items and filter out null/falsy children', async () => {
45
+ render( /*#__PURE__*/React.createElement(InlineList, null, _InlineList$Item || (_InlineList$Item = /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 1")), _InlineList$Item2 || (_InlineList$Item2 = /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 2")), _InlineList$Item3 || (_InlineList$Item3 = /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 3")), _InlineList$Item4 || (_InlineList$Item4 = /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 4")), null && (_InlineList$Item5 || (_InlineList$Item5 = /*#__PURE__*/React.createElement(InlineList.Item, null, "ignore me 1"))), false && (_InlineList$Item6 || (_InlineList$Item6 = /*#__PURE__*/React.createElement(InlineList.Item, null, "ignore me 2")))));
46
+ const listItems = screen.getAllByRole('listitem');
47
+ expect(listItems.length).toEqual(4);
48
+ });
49
+ it('should render a delimiter when delimiter="pipe"', async () => {
50
+ const _render = render(_InlineList || (_InlineList = /*#__PURE__*/React.createElement(InlineList, {
51
+ delimiter: "pipe"
52
+ }, /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 1"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 2"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 3"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 4")))),
53
+ container = _render.container;
54
+ const delimiters = container.querySelectorAll('span[aria-hidden="true"]');
55
+ expect(delimiters.length).toEqual(4);
56
+ delimiters.forEach(delimiter => {
57
+ expect(delimiter.getAttribute('class')).toContain('inlineListItem__delimiter');
58
+ });
59
+ });
60
+ it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
61
+ render(_InlineList2 || (_InlineList2 = /*#__PURE__*/React.createElement(InlineList, {
62
+ delimiter: "pipe",
63
+ itemSpacing: "large"
64
+ }, /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 1"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 2"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 3"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 4"))));
65
+ const warning = `Warning: [InlineList] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`;
66
+ expect(consoleErrorMock.mock.calls[0][0]).toBe(warning);
67
+ });
68
+ it('should render an ordered list', async () => {
69
+ render(_InlineList3 || (_InlineList3 = /*#__PURE__*/React.createElement(InlineList, {
70
+ as: "ol"
71
+ }, /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 1"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 2"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 3"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 4"))));
72
+ const list = screen.getByRole('list');
73
+ expect(list.tagName).toBe('OL');
74
+ });
75
+ it('should meet a11y standards', async () => {
76
+ const _render2 = render(_InlineList4 || (_InlineList4 = /*#__PURE__*/React.createElement(InlineList, null, /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 1"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 2"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 3"), /*#__PURE__*/React.createElement(InlineList.Item, null, "List item 4")))),
77
+ container = _render2.container;
78
+ const axeCheck = await runAxeCheck(container);
79
+ expect(axeCheck).toBe(true);
80
+ });
81
+ });
@@ -1,3 +1,4 @@
1
+ var _ListItem;
1
2
  /*
2
3
  * The MIT License (MIT)
3
4
  *
@@ -21,13 +22,24 @@
21
22
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
23
  * SOFTWARE.
23
24
  */
24
- import { locator } from '@instructure/ui-test-locator';
25
- import { InlineListLocator } from '../InlineListLocator';
26
- import { InlineListItem } from './index';
27
25
 
28
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
29
- export const InlineListItemLocator = locator(InlineListItem.selector, {
30
- findNestedOptions: (...args) => {
31
- return InlineListLocator.find(...args);
32
- }
26
+ import React from 'react';
27
+ import '@testing-library/jest-dom';
28
+ import { render, screen } from '@testing-library/react';
29
+ import { vi } from 'vitest';
30
+ import { ListItem } from '../index';
31
+ describe('<ListItem />', () => {
32
+ it('should render children', async () => {
33
+ render(_ListItem || (_ListItem = /*#__PURE__*/React.createElement(ListItem, null, "hello")));
34
+ const listItem = screen.getByRole('listitem');
35
+ expect(listItem).toHaveTextContent('hello');
36
+ });
37
+ it('should call elementRef', async () => {
38
+ const elementRef = vi.fn();
39
+ render( /*#__PURE__*/React.createElement(ListItem, {
40
+ elementRef: elementRef
41
+ }, "List item"));
42
+ const listItem = screen.getByRole('listitem');
43
+ expect(elementRef).toHaveBeenCalledWith(listItem);
44
+ });
33
45
  });
@@ -0,0 +1,70 @@
1
+ var _List$Item, _List$Item2, _List$Item3, _List$Item4, _List$Item5, _List$Item6, _List, _List2, _List3;
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 '@testing-library/jest-dom';
28
+ import { render, screen } from '@testing-library/react';
29
+ import { vi } from 'vitest';
30
+ import { List } from '../index';
31
+ import { runAxeCheck } from '@instructure/ui-axe-check';
32
+ describe('<List />', () => {
33
+ let consoleWarningMock;
34
+ let consoleErrorMock;
35
+ beforeEach(() => {
36
+ // Mocking console to prevent test output pollution and expect for messages
37
+ consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
38
+ consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
39
+ });
40
+ afterEach(() => {
41
+ consoleWarningMock.mockRestore();
42
+ consoleErrorMock.mockRestore();
43
+ });
44
+ it('should render list items and filter out null/falsy children', async () => {
45
+ render( /*#__PURE__*/React.createElement(List, null, _List$Item || (_List$Item = /*#__PURE__*/React.createElement(List.Item, null, "List item 1")), _List$Item2 || (_List$Item2 = /*#__PURE__*/React.createElement(List.Item, null, "List item 2")), _List$Item3 || (_List$Item3 = /*#__PURE__*/React.createElement(List.Item, null, "List item 3")), _List$Item4 || (_List$Item4 = /*#__PURE__*/React.createElement(List.Item, null, "List item 4")), null && (_List$Item5 || (_List$Item5 = /*#__PURE__*/React.createElement(List.Item, null, "ignore me 1"))), false && (_List$Item6 || (_List$Item6 = /*#__PURE__*/React.createElement(List.Item, null, "ignore me 2")))));
46
+ const listItems = screen.getAllByRole('listitem');
47
+ expect(listItems.length).toEqual(4);
48
+ });
49
+ it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
50
+ render(_List || (_List = /*#__PURE__*/React.createElement(List, {
51
+ delimiter: "dashed",
52
+ itemSpacing: "large"
53
+ }, /*#__PURE__*/React.createElement(List.Item, null, "List item 1"), /*#__PURE__*/React.createElement(List.Item, null, "List item 2"), /*#__PURE__*/React.createElement(List.Item, null, "List item 3"), /*#__PURE__*/React.createElement(List.Item, null, "List item 4"))));
54
+ const warning = `Warning: [List] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`;
55
+ expect(consoleErrorMock.mock.calls[0][0]).toBe(warning);
56
+ });
57
+ it('should render an ordered list', async () => {
58
+ render(_List2 || (_List2 = /*#__PURE__*/React.createElement(List, {
59
+ as: "ol"
60
+ }, /*#__PURE__*/React.createElement(List.Item, null, "List item 1"), /*#__PURE__*/React.createElement(List.Item, null, "List item 2"), /*#__PURE__*/React.createElement(List.Item, null, "List item 3"), /*#__PURE__*/React.createElement(List.Item, null, "List item 4"))));
61
+ const list = screen.getByRole('list');
62
+ expect(list.tagName).toBe('OL');
63
+ });
64
+ it('should meet a11y standards', async () => {
65
+ const _render = render(_List3 || (_List3 = /*#__PURE__*/React.createElement(List, null, /*#__PURE__*/React.createElement(List.Item, null, "List item 1"), /*#__PURE__*/React.createElement(List.Item, null, "List item 2"), /*#__PURE__*/React.createElement(List.Item, null, "List item 3"), /*#__PURE__*/React.createElement(List.Item, null, "List item 4")))),
66
+ container = _render.container;
67
+ const axeCheck = await runAxeCheck(container);
68
+ expect(axeCheck).toBe(true);
69
+ });
70
+ });
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ require("@testing-library/jest-dom");
6
+ var _react2 = require("@testing-library/react");
7
+ var _vitest = require("vitest");
8
+ var _index = require("../index");
9
+ var _InlineListItem, _InlineListItem2;
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('<InlineListItem />', () => {
34
+ it('should render children', async () => {
35
+ (0, _react2.render)(_InlineListItem || (_InlineListItem = /*#__PURE__*/_react.default.createElement(_index.InlineListItem, null, "hello")));
36
+ const listItem = _react2.screen.getByRole('listitem');
37
+ expect(listItem).toHaveTextContent('hello');
38
+ });
39
+ it('should render delimiter', async () => {
40
+ const _render = (0, _react2.render)(_InlineListItem2 || (_InlineListItem2 = /*#__PURE__*/_react.default.createElement(_index.InlineListItem, {
41
+ delimiter: "slash"
42
+ }, "List item"))),
43
+ container = _render.container;
44
+ const listItem = container.querySelector('span[class$="delimiter"]');
45
+ expect(listItem).toHaveAttribute('aria-hidden', 'true');
46
+ });
47
+ it('should call elementRef', async () => {
48
+ const elementRef = _vitest.vi.fn();
49
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.InlineListItem, {
50
+ elementRef: elementRef
51
+ }, "List item"));
52
+ const listItem = _react2.screen.getByRole('listitem');
53
+ expect(elementRef).toHaveBeenCalledWith(listItem);
54
+ });
55
+ });
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ require("@testing-library/jest-dom");
6
+ var _react2 = require("@testing-library/react");
7
+ var _vitest = require("vitest");
8
+ var _index = require("../index");
9
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
10
+ var _InlineList$Item, _InlineList$Item2, _InlineList$Item3, _InlineList$Item4, _InlineList$Item5, _InlineList$Item6, _InlineList, _InlineList2, _InlineList3, _InlineList4;
11
+ /*
12
+ * The MIT License (MIT)
13
+ *
14
+ * Copyright (c) 2015 - present Instructure, Inc.
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all
24
+ * copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ * SOFTWARE.
33
+ */
34
+ describe('<InlineList />', () => {
35
+ let consoleWarningMock;
36
+ let consoleErrorMock;
37
+ beforeEach(() => {
38
+ // Mocking console to prevent test output pollution and expect for messages
39
+ consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
40
+ consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
41
+ });
42
+ afterEach(() => {
43
+ consoleWarningMock.mockRestore();
44
+ consoleErrorMock.mockRestore();
45
+ });
46
+ it('should render list items and filter out null/falsy children', async () => {
47
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.InlineList, null, _InlineList$Item || (_InlineList$Item = /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 1")), _InlineList$Item2 || (_InlineList$Item2 = /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 2")), _InlineList$Item3 || (_InlineList$Item3 = /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 3")), _InlineList$Item4 || (_InlineList$Item4 = /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 4")), null && (_InlineList$Item5 || (_InlineList$Item5 = /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "ignore me 1"))), false && (_InlineList$Item6 || (_InlineList$Item6 = /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "ignore me 2")))));
48
+ const listItems = _react2.screen.getAllByRole('listitem');
49
+ expect(listItems.length).toEqual(4);
50
+ });
51
+ it('should render a delimiter when delimiter="pipe"', async () => {
52
+ const _render = (0, _react2.render)(_InlineList || (_InlineList = /*#__PURE__*/_react.default.createElement(_index.InlineList, {
53
+ delimiter: "pipe"
54
+ }, /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 1"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 2"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 3"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 4")))),
55
+ container = _render.container;
56
+ const delimiters = container.querySelectorAll('span[aria-hidden="true"]');
57
+ expect(delimiters.length).toEqual(4);
58
+ delimiters.forEach(delimiter => {
59
+ expect(delimiter.getAttribute('class')).toContain('inlineListItem__delimiter');
60
+ });
61
+ });
62
+ it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
63
+ (0, _react2.render)(_InlineList2 || (_InlineList2 = /*#__PURE__*/_react.default.createElement(_index.InlineList, {
64
+ delimiter: "pipe",
65
+ itemSpacing: "large"
66
+ }, /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 1"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 2"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 3"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 4"))));
67
+ const warning = `Warning: [InlineList] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`;
68
+ expect(consoleErrorMock.mock.calls[0][0]).toBe(warning);
69
+ });
70
+ it('should render an ordered list', async () => {
71
+ (0, _react2.render)(_InlineList3 || (_InlineList3 = /*#__PURE__*/_react.default.createElement(_index.InlineList, {
72
+ as: "ol"
73
+ }, /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 1"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 2"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 3"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 4"))));
74
+ const list = _react2.screen.getByRole('list');
75
+ expect(list.tagName).toBe('OL');
76
+ });
77
+ it('should meet a11y standards', async () => {
78
+ const _render2 = (0, _react2.render)(_InlineList4 || (_InlineList4 = /*#__PURE__*/_react.default.createElement(_index.InlineList, null, /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 1"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 2"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 3"), /*#__PURE__*/_react.default.createElement(_index.InlineList.Item, null, "List item 4")))),
79
+ container = _render2.container;
80
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
81
+ expect(axeCheck).toBe(true);
82
+ });
83
+ });
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
 
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.InlineListItemLocator = void 0;
7
- var _locator = require("@instructure/ui-test-locator/lib/utils/locator.js");
8
- var _InlineListLocator = require("../InlineListLocator");
9
- var _index = require("./index");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ require("@testing-library/jest-dom");
6
+ var _react2 = require("@testing-library/react");
7
+ var _vitest = require("vitest");
8
+ var _index = require("../index");
9
+ var _ListItem;
10
10
  /*
11
11
  * The MIT License (MIT)
12
12
  *
@@ -30,10 +30,18 @@ var _index = require("./index");
30
30
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
31
31
  * SOFTWARE.
32
32
  */
33
-
34
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
35
- const InlineListItemLocator = exports.InlineListItemLocator = (0, _locator.locator)(_index.InlineListItem.selector, {
36
- findNestedOptions: (...args) => {
37
- return _InlineListLocator.InlineListLocator.find(...args);
38
- }
33
+ describe('<ListItem />', () => {
34
+ it('should render children', async () => {
35
+ (0, _react2.render)(_ListItem || (_ListItem = /*#__PURE__*/_react.default.createElement(_index.ListItem, null, "hello")));
36
+ const listItem = _react2.screen.getByRole('listitem');
37
+ expect(listItem).toHaveTextContent('hello');
38
+ });
39
+ it('should call elementRef', async () => {
40
+ const elementRef = _vitest.vi.fn();
41
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.ListItem, {
42
+ elementRef: elementRef
43
+ }, "List item"));
44
+ const listItem = _react2.screen.getByRole('listitem');
45
+ expect(elementRef).toHaveBeenCalledWith(listItem);
46
+ });
39
47
  });
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
+ var _react = _interopRequireDefault(require("react"));
5
+ require("@testing-library/jest-dom");
6
+ var _react2 = require("@testing-library/react");
7
+ var _vitest = require("vitest");
8
+ var _index = require("../index");
9
+ var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
10
+ var _List$Item, _List$Item2, _List$Item3, _List$Item4, _List$Item5, _List$Item6, _List, _List2, _List3;
11
+ /*
12
+ * The MIT License (MIT)
13
+ *
14
+ * Copyright (c) 2015 - present Instructure, Inc.
15
+ *
16
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
17
+ * of this software and associated documentation files (the "Software"), to deal
18
+ * in the Software without restriction, including without limitation the rights
19
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
+ * copies of the Software, and to permit persons to whom the Software is
21
+ * furnished to do so, subject to the following conditions:
22
+ *
23
+ * The above copyright notice and this permission notice shall be included in all
24
+ * copies or substantial portions of the Software.
25
+ *
26
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
+ * SOFTWARE.
33
+ */
34
+ describe('<List />', () => {
35
+ let consoleWarningMock;
36
+ let consoleErrorMock;
37
+ beforeEach(() => {
38
+ // Mocking console to prevent test output pollution and expect for messages
39
+ consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
40
+ consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
41
+ });
42
+ afterEach(() => {
43
+ consoleWarningMock.mockRestore();
44
+ consoleErrorMock.mockRestore();
45
+ });
46
+ it('should render list items and filter out null/falsy children', async () => {
47
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.List, null, _List$Item || (_List$Item = /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 1")), _List$Item2 || (_List$Item2 = /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 2")), _List$Item3 || (_List$Item3 = /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 3")), _List$Item4 || (_List$Item4 = /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 4")), null && (_List$Item5 || (_List$Item5 = /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "ignore me 1"))), false && (_List$Item6 || (_List$Item6 = /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "ignore me 2")))));
48
+ const listItems = _react2.screen.getAllByRole('listitem');
49
+ expect(listItems.length).toEqual(4);
50
+ });
51
+ it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
52
+ (0, _react2.render)(_List || (_List = /*#__PURE__*/_react.default.createElement(_index.List, {
53
+ delimiter: "dashed",
54
+ itemSpacing: "large"
55
+ }, /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 1"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 2"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 3"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 4"))));
56
+ const warning = `Warning: [List] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`;
57
+ expect(consoleErrorMock.mock.calls[0][0]).toBe(warning);
58
+ });
59
+ it('should render an ordered list', async () => {
60
+ (0, _react2.render)(_List2 || (_List2 = /*#__PURE__*/_react.default.createElement(_index.List, {
61
+ as: "ol"
62
+ }, /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 1"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 2"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 3"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 4"))));
63
+ const list = _react2.screen.getByRole('list');
64
+ expect(list.tagName).toBe('OL');
65
+ });
66
+ it('should meet a11y standards', async () => {
67
+ const _render = (0, _react2.render)(_List3 || (_List3 = /*#__PURE__*/_react.default.createElement(_index.List, null, /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 1"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 2"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 3"), /*#__PURE__*/_react.default.createElement(_index.List.Item, null, "List item 4")))),
68
+ container = _render.container;
69
+ const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
70
+ expect(axeCheck).toBe(true);
71
+ });
72
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-list",
3
- "version": "10.0.1-snapshot-5",
3
+ "version": "10.0.1-snapshot-7",
4
4
  "description": "Components for displaying vertical or horizontal lists.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -24,21 +24,24 @@
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
26
  "@babel/runtime": "^7.24.5",
27
- "@instructure/console": "10.0.1-snapshot-5",
28
- "@instructure/emotion": "10.0.1-snapshot-5",
29
- "@instructure/shared-types": "10.0.1-snapshot-5",
30
- "@instructure/ui-prop-types": "10.0.1-snapshot-5",
31
- "@instructure/ui-react-utils": "10.0.1-snapshot-5",
32
- "@instructure/ui-testable": "10.0.1-snapshot-5",
33
- "@instructure/ui-view": "10.0.1-snapshot-5",
27
+ "@instructure/console": "10.0.1-snapshot-7",
28
+ "@instructure/emotion": "10.0.1-snapshot-7",
29
+ "@instructure/shared-types": "10.0.1-snapshot-7",
30
+ "@instructure/ui-prop-types": "10.0.1-snapshot-7",
31
+ "@instructure/ui-react-utils": "10.0.1-snapshot-7",
32
+ "@instructure/ui-testable": "10.0.1-snapshot-7",
33
+ "@instructure/ui-view": "10.0.1-snapshot-7",
34
34
  "prop-types": "^15.8.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@instructure/ui-babel-preset": "10.0.1-snapshot-5",
38
- "@instructure/ui-color-utils": "10.0.1-snapshot-5",
39
- "@instructure/ui-test-locator": "10.0.1-snapshot-5",
40
- "@instructure/ui-test-utils": "10.0.1-snapshot-5",
41
- "@instructure/ui-themes": "10.0.1-snapshot-5"
37
+ "@instructure/ui-axe-check": "10.0.1-snapshot-7",
38
+ "@instructure/ui-babel-preset": "10.0.1-snapshot-7",
39
+ "@instructure/ui-color-utils": "10.0.1-snapshot-7",
40
+ "@instructure/ui-test-utils": "10.0.1-snapshot-7",
41
+ "@instructure/ui-themes": "10.0.1-snapshot-7",
42
+ "@testing-library/jest-dom": "^6.4.6",
43
+ "@testing-library/react": "^15.0.7",
44
+ "vitest": "^2.0.2"
42
45
  },
43
46
  "peerDependencies": {
44
47
  "react": ">=16.8 <=18"
@@ -21,19 +21,36 @@
21
21
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
22
  * SOFTWARE.
23
23
  */
24
- import { locator } from '@instructure/ui-test-locator'
25
24
 
26
- import { InlineList } from './index'
25
+ import React from 'react'
26
+ import '@testing-library/jest-dom'
27
+ import { render, screen } from '@testing-library/react'
28
+ import { vi } from 'vitest'
27
29
 
28
- import { InlineListItemLocator } from './InlineListItem/InlineListItemLocator'
30
+ import { InlineListItem } from '../index'
29
31
 
30
- // @ts-expect-error ts-migrate(2339) FIXME: Property 'selector' does not exist on type 'typeof... Remove this comment to see the full error message
31
- export const InlineListLocator = locator(InlineList.selector, {
32
- findAllItems: (...args: any[]) => {
33
- return InlineListItemLocator.findAll(...args)
34
- },
32
+ describe('<InlineListItem />', () => {
33
+ it('should render children', async () => {
34
+ render(<InlineListItem>hello</InlineListItem>)
35
+ const listItem = screen.getByRole('listitem')
35
36
 
36
- findItem: (...args: any[]) => {
37
- return InlineListItemLocator.find(...args)
38
- }
37
+ expect(listItem).toHaveTextContent('hello')
38
+ })
39
+
40
+ it('should render delimiter', async () => {
41
+ const { container } = render(
42
+ <InlineListItem delimiter="slash">List item</InlineListItem>
43
+ )
44
+ const listItem = container.querySelector('span[class$="delimiter"]')
45
+
46
+ expect(listItem).toHaveAttribute('aria-hidden', 'true')
47
+ })
48
+
49
+ it('should call elementRef', async () => {
50
+ const elementRef = vi.fn()
51
+ render(<InlineListItem elementRef={elementRef}>List item</InlineListItem>)
52
+ const listItem = screen.getByRole('listitem')
53
+
54
+ expect(elementRef).toHaveBeenCalledWith(listItem)
55
+ })
39
56
  })