@instructure/ui-metric 10.2.0 → 10.2.1-snapshot-1
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 +8 -0
- package/es/Metric/__new-tests__/Metric.test.js +95 -0
- package/es/MetricGroup/__new-tests__/MetricGroup.test.js +133 -0
- package/lib/Metric/__new-tests__/Metric.test.js +97 -0
- package/lib/MetricGroup/__new-tests__/MetricGroup.test.js +135 -0
- package/package.json +15 -12
- package/src/Metric/__new-tests__/Metric.test.tsx +96 -0
- package/src/MetricGroup/__new-tests__/MetricGroup.test.tsx +125 -0
- package/tsconfig.build.json +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/Metric/__new-tests__/Metric.test.d.ts +2 -0
- package/types/Metric/__new-tests__/Metric.test.d.ts.map +1 -0
- package/types/MetricGroup/__new-tests__/MetricGroup.test.d.ts +2 -0
- package/types/MetricGroup/__new-tests__/MetricGroup.test.d.ts.map +1 -0
- package/es/Metric/MetricLocator.js +0 -28
- package/es/Metric/locator.js +0 -26
- package/es/MetricGroup/MetricGroupLocator.js +0 -39
- package/es/MetricGroup/locator.js +0 -26
- package/lib/Metric/MetricLocator.js +0 -34
- package/lib/Metric/locator.js +0 -37
- package/lib/MetricGroup/MetricGroupLocator.js +0 -45
- package/lib/MetricGroup/locator.js +0 -37
- package/src/Metric/MetricLocator.ts +0 -29
- package/src/Metric/locator.ts +0 -27
- package/src/MetricGroup/MetricGroupLocator.ts +0 -40
- package/src/MetricGroup/locator.ts +0 -27
- package/types/Metric/MetricLocator.d.ts +0 -428
- package/types/Metric/MetricLocator.d.ts.map +0 -1
- package/types/Metric/locator.d.ts +0 -4
- package/types/Metric/locator.d.ts.map +0 -1
- package/types/MetricGroup/MetricGroupLocator.d.ts +0 -1823
- package/types/MetricGroup/MetricGroupLocator.d.ts.map +0 -1
- package/types/MetricGroup/locator.d.ts +0 -4
- package/types/MetricGroup/locator.d.ts.map +0 -1
|
@@ -0,0 +1,125 @@
|
|
|
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 React from 'react'
|
|
26
|
+
import { render, screen } from '@testing-library/react'
|
|
27
|
+
import '@testing-library/jest-dom'
|
|
28
|
+
import { vi } from 'vitest'
|
|
29
|
+
|
|
30
|
+
import { runAxeCheck } from '@instructure/ui-axe-check'
|
|
31
|
+
import { MetricGroup } from '../index'
|
|
32
|
+
import { Metric } from '../../Metric'
|
|
33
|
+
|
|
34
|
+
describe('<MetricGroup />', () => {
|
|
35
|
+
let consoleErrorMock: any
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
// Mocking console to prevent test output pollution and expect for messages
|
|
39
|
+
consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
consoleErrorMock.mockRestore()
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
it('should render children', async () => {
|
|
47
|
+
const { container } = render(
|
|
48
|
+
<MetricGroup>
|
|
49
|
+
<Metric renderLabel="Grade" renderValue="80%" />
|
|
50
|
+
<Metric renderLabel="Late" renderValue="4" />
|
|
51
|
+
<Metric renderLabel="Missing" renderValue="2" />
|
|
52
|
+
</MetricGroup>
|
|
53
|
+
)
|
|
54
|
+
|
|
55
|
+
expect(container).toHaveTextContent('Grade80%Late4Missing2')
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
it('passes props through to MetricGroup element', async () => {
|
|
59
|
+
render(
|
|
60
|
+
<MetricGroup data-testid="metric-group" data-automation="foo">
|
|
61
|
+
<Metric renderLabel="Grade" renderValue="80%" />
|
|
62
|
+
<Metric renderLabel="Late" renderValue="4" />
|
|
63
|
+
<Metric renderLabel="Missing" renderValue="2" />
|
|
64
|
+
</MetricGroup>
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
const metric = screen.getByTestId('metric-group')
|
|
68
|
+
expect(metric).toHaveAttribute('data-automation', 'foo')
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
describe('for a11y', () => {
|
|
72
|
+
it('should meet standards', async () => {
|
|
73
|
+
const { container } = render(
|
|
74
|
+
<MetricGroup>
|
|
75
|
+
<Metric renderLabel="Grade" renderValue="80%" />
|
|
76
|
+
<Metric renderLabel="Late" renderValue="4" />
|
|
77
|
+
<Metric renderLabel="Missing" renderValue="2" />
|
|
78
|
+
</MetricGroup>
|
|
79
|
+
)
|
|
80
|
+
const axeCheck = await runAxeCheck(container)
|
|
81
|
+
|
|
82
|
+
expect(axeCheck).toBe(true)
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
it('should have role=grid with aria-readonly=true', async () => {
|
|
86
|
+
render(
|
|
87
|
+
<MetricGroup>
|
|
88
|
+
<Metric renderLabel="Grade" renderValue="80%" />
|
|
89
|
+
<Metric renderLabel="Late" renderValue="4" />
|
|
90
|
+
<Metric renderLabel="Missing" renderValue="2" />
|
|
91
|
+
</MetricGroup>
|
|
92
|
+
)
|
|
93
|
+
const grids = screen.getAllByRole('grid')
|
|
94
|
+
|
|
95
|
+
expect(grids.length).toBe(1)
|
|
96
|
+
expect(grids[0]).toHaveAttribute('aria-readonly', 'true')
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should have role=row', async () => {
|
|
100
|
+
render(
|
|
101
|
+
<MetricGroup>
|
|
102
|
+
<Metric renderLabel="Grade" renderValue="80%" />
|
|
103
|
+
<Metric renderLabel="Late" renderValue="4" />
|
|
104
|
+
<Metric renderLabel="Missing" renderValue="2" />
|
|
105
|
+
</MetricGroup>
|
|
106
|
+
)
|
|
107
|
+
const rows = screen.getAllByRole('row')
|
|
108
|
+
|
|
109
|
+
expect(rows.length).toBe(3)
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
it('should have role=gridcell', async () => {
|
|
113
|
+
render(
|
|
114
|
+
<MetricGroup>
|
|
115
|
+
<Metric renderLabel="Grade" renderValue="80%" />
|
|
116
|
+
<Metric renderLabel="Late" renderValue="4" />
|
|
117
|
+
<Metric renderLabel="Missing" renderValue="2" />
|
|
118
|
+
</MetricGroup>
|
|
119
|
+
)
|
|
120
|
+
const cells = screen.getAllByRole('gridcell')
|
|
121
|
+
|
|
122
|
+
expect(cells.length).toBe(3)
|
|
123
|
+
})
|
|
124
|
+
})
|
|
125
|
+
})
|
package/tsconfig.build.json
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
{ "path": "../console/tsconfig.build.json" },
|
|
11
11
|
{ "path": "../emotion/tsconfig.build.json" },
|
|
12
12
|
{ "path": "../shared-types/tsconfig.build.json" },
|
|
13
|
+
{ "path": "../ui-axe-check/tsconfig.build.json" },
|
|
13
14
|
{ "path": "../ui-prop-types/tsconfig.build.json" },
|
|
14
15
|
{ "path": "../ui-react-utils/tsconfig.build.json" },
|
|
15
16
|
{ "path": "../ui-testable/tsconfig.build.json" },
|
|
16
17
|
{ "path": "../ui-babel-preset/tsconfig.build.json" },
|
|
17
18
|
{ "path": "../ui-color-utils/tsconfig.build.json" },
|
|
18
|
-
{ "path": "../ui-test-locator/tsconfig.build.json" },
|
|
19
19
|
{ "path": "../ui-test-utils/tsconfig.build.json" },
|
|
20
20
|
{ "path": "../ui-themes/tsconfig.build.json" }
|
|
21
21
|
]
|