@instructure/ui-list 10.19.2-snapshot-3 → 10.19.2-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/package.json +13 -13
- package/tsconfig.build.tsbuildinfo +1 -1
- package/es/InlineList/InlineListItem/__new-tests__/InlineListItem.test.js +0 -57
- package/es/InlineList/__new-tests__/InlineList.test.js +0 -128
- package/es/List/ListItem/__new-tests__/ListItem.test.js +0 -48
- package/es/List/__new-tests__/List.test.js +0 -108
- package/lib/InlineList/InlineListItem/__new-tests__/InlineListItem.test.js +0 -58
- package/lib/InlineList/__new-tests__/InlineList.test.js +0 -129
- package/lib/List/ListItem/__new-tests__/ListItem.test.js +0 -49
- package/lib/List/__new-tests__/List.test.js +0 -109
- package/src/InlineList/InlineListItem/__new-tests__/InlineListItem.test.tsx +0 -55
- package/src/InlineList/__new-tests__/InlineList.test.tsx +0 -127
- package/src/List/ListItem/__new-tests__/ListItem.test.tsx +0 -46
- package/src/List/__new-tests__/List.test.tsx +0 -108
- package/types/InlineList/InlineListItem/__new-tests__/InlineListItem.test.d.ts +0 -2
- package/types/InlineList/InlineListItem/__new-tests__/InlineListItem.test.d.ts.map +0 -1
- package/types/InlineList/__new-tests__/InlineList.test.d.ts +0 -2
- package/types/InlineList/__new-tests__/InlineList.test.d.ts.map +0 -1
- package/types/List/ListItem/__new-tests__/ListItem.test.d.ts +0 -2
- package/types/List/ListItem/__new-tests__/ListItem.test.d.ts.map +0 -1
- package/types/List/__new-tests__/List.test.d.ts +0 -2
- package/types/List/__new-tests__/List.test.d.ts.map +0 -1
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
require("@testing-library/jest-dom");
|
|
4
|
-
var _react = require("@testing-library/react");
|
|
5
|
-
var _vitest = require("vitest");
|
|
6
|
-
var _index = require("../index");
|
|
7
|
-
var _runAxeCheck = require("@instructure/ui-axe-check/lib/runAxeCheck.js");
|
|
8
|
-
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
|
9
|
-
var _List, _List2, _List3, _List4;
|
|
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('<List />', () => {
|
|
34
|
-
let consoleWarningMock;
|
|
35
|
-
let consoleErrorMock;
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
// Mocking console to prevent test output pollution and expect for messages
|
|
38
|
-
consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
39
|
-
consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
|
|
40
|
-
});
|
|
41
|
-
afterEach(() => {
|
|
42
|
-
consoleWarningMock.mockRestore();
|
|
43
|
-
consoleErrorMock.mockRestore();
|
|
44
|
-
});
|
|
45
|
-
it('should render list items and filter out null/falsy children', async () => {
|
|
46
|
-
(0, _react.render)(_List || (_List = (0, _jsxRuntime.jsxs)(_index.List, {
|
|
47
|
-
children: [(0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
48
|
-
children: "List item 1"
|
|
49
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
50
|
-
children: "List item 2"
|
|
51
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
52
|
-
children: "List item 3"
|
|
53
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
54
|
-
children: "List item 4"
|
|
55
|
-
}), null, false]
|
|
56
|
-
})));
|
|
57
|
-
const listItems = _react.screen.getAllByRole('listitem');
|
|
58
|
-
expect(listItems.length).toEqual(4);
|
|
59
|
-
});
|
|
60
|
-
it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
|
|
61
|
-
(0, _react.render)(_List2 || (_List2 = (0, _jsxRuntime.jsxs)(_index.List, {
|
|
62
|
-
delimiter: "dashed",
|
|
63
|
-
itemSpacing: "large",
|
|
64
|
-
children: [(0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
65
|
-
children: "List item 1"
|
|
66
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
67
|
-
children: "List item 2"
|
|
68
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
69
|
-
children: "List item 3"
|
|
70
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
71
|
-
children: "List item 4"
|
|
72
|
-
})]
|
|
73
|
-
})));
|
|
74
|
-
const warning = `Warning: [List] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`;
|
|
75
|
-
expect(consoleErrorMock.mock.calls[0][0]).toBe(warning);
|
|
76
|
-
});
|
|
77
|
-
it('should render an ordered list', async () => {
|
|
78
|
-
(0, _react.render)(_List3 || (_List3 = (0, _jsxRuntime.jsxs)(_index.List, {
|
|
79
|
-
as: "ol",
|
|
80
|
-
children: [(0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
81
|
-
children: "List item 1"
|
|
82
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
83
|
-
children: "List item 2"
|
|
84
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
85
|
-
children: "List item 3"
|
|
86
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
87
|
-
children: "List item 4"
|
|
88
|
-
})]
|
|
89
|
-
})));
|
|
90
|
-
const list = _react.screen.getByRole('list');
|
|
91
|
-
expect(list.tagName).toBe('OL');
|
|
92
|
-
});
|
|
93
|
-
it('should meet a11y standards', async () => {
|
|
94
|
-
const _render = (0, _react.render)(_List4 || (_List4 = (0, _jsxRuntime.jsxs)(_index.List, {
|
|
95
|
-
children: [(0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
96
|
-
children: "List item 1"
|
|
97
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
98
|
-
children: "List item 2"
|
|
99
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
100
|
-
children: "List item 3"
|
|
101
|
-
}), (0, _jsxRuntime.jsx)(_index.List.Item, {
|
|
102
|
-
children: "List item 4"
|
|
103
|
-
})]
|
|
104
|
-
}))),
|
|
105
|
-
container = _render.container;
|
|
106
|
-
const axeCheck = await (0, _runAxeCheck.runAxeCheck)(container);
|
|
107
|
-
expect(axeCheck).toBe(true);
|
|
108
|
-
});
|
|
109
|
-
});
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import '@testing-library/jest-dom'
|
|
26
|
-
import { render, screen } from '@testing-library/react'
|
|
27
|
-
import { vi } from 'vitest'
|
|
28
|
-
|
|
29
|
-
import { InlineListItem } from '../index'
|
|
30
|
-
|
|
31
|
-
describe('<InlineListItem />', () => {
|
|
32
|
-
it('should render children', async () => {
|
|
33
|
-
render(<InlineListItem>hello</InlineListItem>)
|
|
34
|
-
const listItem = screen.getByRole('listitem')
|
|
35
|
-
|
|
36
|
-
expect(listItem).toHaveTextContent('hello')
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should render delimiter', async () => {
|
|
40
|
-
const { container } = render(
|
|
41
|
-
<InlineListItem delimiter="slash">List item</InlineListItem>
|
|
42
|
-
)
|
|
43
|
-
const listItem = container.querySelector('span[class$="delimiter"]')
|
|
44
|
-
|
|
45
|
-
expect(listItem).toHaveAttribute('aria-hidden', 'true')
|
|
46
|
-
})
|
|
47
|
-
|
|
48
|
-
it('should call elementRef', async () => {
|
|
49
|
-
const elementRef = vi.fn()
|
|
50
|
-
render(<InlineListItem elementRef={elementRef}>List item</InlineListItem>)
|
|
51
|
-
const listItem = screen.getByRole('listitem')
|
|
52
|
-
|
|
53
|
-
expect(elementRef).toHaveBeenCalledWith(listItem)
|
|
54
|
-
})
|
|
55
|
-
})
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import '@testing-library/jest-dom'
|
|
26
|
-
import { render, screen } from '@testing-library/react'
|
|
27
|
-
import { vi } from 'vitest'
|
|
28
|
-
|
|
29
|
-
import { InlineList } from '../index'
|
|
30
|
-
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
31
|
-
|
|
32
|
-
describe('<InlineList />', () => {
|
|
33
|
-
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
34
|
-
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
35
|
-
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
// Mocking console to prevent test output pollution and expect for messages
|
|
38
|
-
consoleWarningMock = vi
|
|
39
|
-
.spyOn(console, 'warn')
|
|
40
|
-
.mockImplementation(() => {}) as any
|
|
41
|
-
consoleErrorMock = vi
|
|
42
|
-
.spyOn(console, 'error')
|
|
43
|
-
.mockImplementation(() => {}) as any
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
consoleWarningMock.mockRestore()
|
|
48
|
-
consoleErrorMock.mockRestore()
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('should render list items and filter out null/falsy children', async () => {
|
|
52
|
-
render(
|
|
53
|
-
<InlineList>
|
|
54
|
-
<InlineList.Item>List item 1</InlineList.Item>
|
|
55
|
-
<InlineList.Item>List item 2</InlineList.Item>
|
|
56
|
-
<InlineList.Item>List item 3</InlineList.Item>
|
|
57
|
-
<InlineList.Item>List item 4</InlineList.Item>
|
|
58
|
-
{null}
|
|
59
|
-
{false}
|
|
60
|
-
</InlineList>
|
|
61
|
-
)
|
|
62
|
-
const listItems = screen.getAllByRole('listitem')
|
|
63
|
-
|
|
64
|
-
expect(listItems.length).toEqual(4)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('should render a delimiter when delimiter="pipe"', async () => {
|
|
68
|
-
const { container } = render(
|
|
69
|
-
<InlineList delimiter="pipe">
|
|
70
|
-
<InlineList.Item>List item 1</InlineList.Item>
|
|
71
|
-
<InlineList.Item>List item 2</InlineList.Item>
|
|
72
|
-
<InlineList.Item>List item 3</InlineList.Item>
|
|
73
|
-
<InlineList.Item>List item 4</InlineList.Item>
|
|
74
|
-
</InlineList>
|
|
75
|
-
)
|
|
76
|
-
const delimiters = container.querySelectorAll('span[aria-hidden="true"]')
|
|
77
|
-
|
|
78
|
-
expect(delimiters.length).toEqual(4)
|
|
79
|
-
delimiters.forEach((delimiter) => {
|
|
80
|
-
expect(delimiter.getAttribute('class')).toContain(
|
|
81
|
-
'inlineListItem__delimiter'
|
|
82
|
-
)
|
|
83
|
-
})
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
|
|
87
|
-
render(
|
|
88
|
-
<InlineList delimiter="pipe" itemSpacing="large">
|
|
89
|
-
<InlineList.Item>List item 1</InlineList.Item>
|
|
90
|
-
<InlineList.Item>List item 2</InlineList.Item>
|
|
91
|
-
<InlineList.Item>List item 3</InlineList.Item>
|
|
92
|
-
<InlineList.Item>List item 4</InlineList.Item>
|
|
93
|
-
</InlineList>
|
|
94
|
-
)
|
|
95
|
-
const warning = `Warning: [InlineList] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`
|
|
96
|
-
|
|
97
|
-
expect(consoleErrorMock.mock.calls[0][0]).toBe(warning)
|
|
98
|
-
})
|
|
99
|
-
|
|
100
|
-
it('should render an ordered list', async () => {
|
|
101
|
-
render(
|
|
102
|
-
<InlineList as="ol">
|
|
103
|
-
<InlineList.Item>List item 1</InlineList.Item>
|
|
104
|
-
<InlineList.Item>List item 2</InlineList.Item>
|
|
105
|
-
<InlineList.Item>List item 3</InlineList.Item>
|
|
106
|
-
<InlineList.Item>List item 4</InlineList.Item>
|
|
107
|
-
</InlineList>
|
|
108
|
-
)
|
|
109
|
-
const list = screen.getByRole('list')
|
|
110
|
-
|
|
111
|
-
expect(list.tagName).toBe('OL')
|
|
112
|
-
})
|
|
113
|
-
|
|
114
|
-
it('should meet a11y standards', async () => {
|
|
115
|
-
const { container } = render(
|
|
116
|
-
<InlineList>
|
|
117
|
-
<InlineList.Item>List item 1</InlineList.Item>
|
|
118
|
-
<InlineList.Item>List item 2</InlineList.Item>
|
|
119
|
-
<InlineList.Item>List item 3</InlineList.Item>
|
|
120
|
-
<InlineList.Item>List item 4</InlineList.Item>
|
|
121
|
-
</InlineList>
|
|
122
|
-
)
|
|
123
|
-
const axeCheck = await runAxeCheck(container)
|
|
124
|
-
|
|
125
|
-
expect(axeCheck).toBe(true)
|
|
126
|
-
})
|
|
127
|
-
})
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import '@testing-library/jest-dom'
|
|
26
|
-
import { render, screen } from '@testing-library/react'
|
|
27
|
-
import { vi } from 'vitest'
|
|
28
|
-
|
|
29
|
-
import { ListItem } from '../index'
|
|
30
|
-
|
|
31
|
-
describe('<ListItem />', () => {
|
|
32
|
-
it('should render children', async () => {
|
|
33
|
-
render(<ListItem>hello</ListItem>)
|
|
34
|
-
const listItem = screen.getByRole('listitem')
|
|
35
|
-
|
|
36
|
-
expect(listItem).toHaveTextContent('hello')
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('should call elementRef', async () => {
|
|
40
|
-
const elementRef = vi.fn()
|
|
41
|
-
render(<ListItem elementRef={elementRef}>List item</ListItem>)
|
|
42
|
-
const listItem = screen.getByRole('listitem')
|
|
43
|
-
|
|
44
|
-
expect(elementRef).toHaveBeenCalledWith(listItem)
|
|
45
|
-
})
|
|
46
|
-
})
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* The MIT License (MIT)
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2015 - present Instructure, Inc.
|
|
5
|
-
*
|
|
6
|
-
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
-
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
-
* in the Software without restriction, including without limitation the rights
|
|
9
|
-
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
-
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
-
* furnished to do so, subject to the following conditions:
|
|
12
|
-
*
|
|
13
|
-
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
-
* copies or substantial portions of the Software.
|
|
15
|
-
*
|
|
16
|
-
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
-
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
-
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
-
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
-
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
-
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
-
* SOFTWARE.
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
import '@testing-library/jest-dom'
|
|
26
|
-
import { render, screen } from '@testing-library/react'
|
|
27
|
-
import { vi } from 'vitest'
|
|
28
|
-
|
|
29
|
-
import { List } from '../index'
|
|
30
|
-
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
31
|
-
|
|
32
|
-
describe('<List />', () => {
|
|
33
|
-
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
34
|
-
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
35
|
-
|
|
36
|
-
beforeEach(() => {
|
|
37
|
-
// Mocking console to prevent test output pollution and expect for messages
|
|
38
|
-
consoleWarningMock = vi
|
|
39
|
-
.spyOn(console, 'warn')
|
|
40
|
-
.mockImplementation(() => {}) as any
|
|
41
|
-
consoleErrorMock = vi
|
|
42
|
-
.spyOn(console, 'error')
|
|
43
|
-
.mockImplementation(() => {}) as any
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
afterEach(() => {
|
|
47
|
-
consoleWarningMock.mockRestore()
|
|
48
|
-
consoleErrorMock.mockRestore()
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
it('should render list items and filter out null/falsy children', async () => {
|
|
52
|
-
render(
|
|
53
|
-
<List>
|
|
54
|
-
<List.Item>List item 1</List.Item>
|
|
55
|
-
<List.Item>List item 2</List.Item>
|
|
56
|
-
<List.Item>List item 3</List.Item>
|
|
57
|
-
<List.Item>List item 4</List.Item>
|
|
58
|
-
{null}
|
|
59
|
-
{false}
|
|
60
|
-
</List>
|
|
61
|
-
)
|
|
62
|
-
const listItems = screen.getAllByRole('listitem')
|
|
63
|
-
|
|
64
|
-
expect(listItems.length).toEqual(4)
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('should warn when itemSpacing is set when delimiter is set to anything other than none', async () => {
|
|
68
|
-
render(
|
|
69
|
-
<List delimiter="dashed" itemSpacing="large">
|
|
70
|
-
<List.Item>List item 1</List.Item>
|
|
71
|
-
<List.Item>List item 2</List.Item>
|
|
72
|
-
<List.Item>List item 3</List.Item>
|
|
73
|
-
<List.Item>List item 4</List.Item>
|
|
74
|
-
</List>
|
|
75
|
-
)
|
|
76
|
-
const warning = `Warning: [List] \`itemSpacing\` has no effect inside Lists with the \`delimiter\` prop set to anything other than \`none\`.`
|
|
77
|
-
|
|
78
|
-
expect(consoleErrorMock.mock.calls[0][0]).toBe(warning)
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('should render an ordered list', async () => {
|
|
82
|
-
render(
|
|
83
|
-
<List as="ol">
|
|
84
|
-
<List.Item>List item 1</List.Item>
|
|
85
|
-
<List.Item>List item 2</List.Item>
|
|
86
|
-
<List.Item>List item 3</List.Item>
|
|
87
|
-
<List.Item>List item 4</List.Item>
|
|
88
|
-
</List>
|
|
89
|
-
)
|
|
90
|
-
const list = screen.getByRole('list')
|
|
91
|
-
|
|
92
|
-
expect(list.tagName).toBe('OL')
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('should meet a11y standards', async () => {
|
|
96
|
-
const { container } = render(
|
|
97
|
-
<List>
|
|
98
|
-
<List.Item>List item 1</List.Item>
|
|
99
|
-
<List.Item>List item 2</List.Item>
|
|
100
|
-
<List.Item>List item 3</List.Item>
|
|
101
|
-
<List.Item>List item 4</List.Item>
|
|
102
|
-
</List>
|
|
103
|
-
)
|
|
104
|
-
const axeCheck = await runAxeCheck(container)
|
|
105
|
-
|
|
106
|
-
expect(axeCheck).toBe(true)
|
|
107
|
-
})
|
|
108
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InlineListItem.test.d.ts","sourceRoot":"","sources":["../../../../src/InlineList/InlineListItem/__new-tests__/InlineListItem.test.tsx"],"names":[],"mappings":"AAwBA,OAAO,2BAA2B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"InlineList.test.d.ts","sourceRoot":"","sources":["../../../src/InlineList/__new-tests__/InlineList.test.tsx"],"names":[],"mappings":"AAwBA,OAAO,2BAA2B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ListItem.test.d.ts","sourceRoot":"","sources":["../../../../src/List/ListItem/__new-tests__/ListItem.test.tsx"],"names":[],"mappings":"AAwBA,OAAO,2BAA2B,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"List.test.d.ts","sourceRoot":"","sources":["../../../src/List/__new-tests__/List.test.tsx"],"names":[],"mappings":"AAwBA,OAAO,2BAA2B,CAAA"}
|