@instructure/ui-drawer-layout 10.2.3-snapshot-8 → 10.2.3-snapshot-10
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/DrawerLayout/DrawerContent/__new-tests__/DrawerContent.test.js +65 -0
- package/es/DrawerLayout/DrawerTray/__new-tests__/DrawerTray.test.js +152 -0
- package/es/DrawerLayout/__new-tests__/DrawerLayout.test.js +49 -0
- package/lib/DrawerLayout/DrawerContent/__new-tests__/DrawerContent.test.js +68 -0
- package/lib/DrawerLayout/DrawerTray/__new-tests__/DrawerTray.test.js +156 -0
- package/lib/DrawerLayout/__new-tests__/DrawerLayout.test.js +52 -0
- package/package.json +23 -21
- package/src/DrawerLayout/DrawerContent/__new-tests__/DrawerContent.test.tsx +70 -0
- package/src/DrawerLayout/DrawerTray/__new-tests__/DrawerTray.test.tsx +187 -0
- package/src/DrawerLayout/{DrawerLayoutLocator.ts → __new-tests__/DrawerLayout.test.tsx} +23 -18
- package/tsconfig.build.json +0 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/types/DrawerLayout/DrawerContent/__new-tests__/DrawerContent.test.d.ts +2 -0
- package/types/DrawerLayout/DrawerContent/__new-tests__/DrawerContent.test.d.ts.map +1 -0
- package/types/DrawerLayout/DrawerTray/__new-tests__/DrawerTray.test.d.ts +2 -0
- package/types/DrawerLayout/DrawerTray/__new-tests__/DrawerTray.test.d.ts.map +1 -0
- package/types/DrawerLayout/__new-tests__/DrawerLayout.test.d.ts +2 -0
- package/types/DrawerLayout/__new-tests__/DrawerLayout.test.d.ts.map +1 -0
- package/es/DrawerLayout/DrawerContent/DrawerContentLocator.js +0 -29
- package/es/DrawerLayout/DrawerLayoutLocator.js +0 -42
- package/es/DrawerLayout/DrawerTray/DrawerTrayLocator.js +0 -29
- package/es/DrawerLayout/locator.js +0 -28
- package/lib/DrawerLayout/DrawerContent/DrawerContentLocator.js +0 -34
- package/lib/DrawerLayout/DrawerLayoutLocator.js +0 -58
- package/lib/DrawerLayout/DrawerTray/DrawerTrayLocator.js +0 -34
- package/lib/DrawerLayout/locator.js +0 -49
- package/src/DrawerLayout/DrawerContent/DrawerContentLocator.ts +0 -30
- package/src/DrawerLayout/DrawerTray/DrawerTrayLocator.ts +0 -30
- package/src/DrawerLayout/locator.ts +0 -30
- package/types/DrawerLayout/DrawerContent/DrawerContentLocator.d.ts +0 -428
- package/types/DrawerLayout/DrawerContent/DrawerContentLocator.d.ts.map +0 -1
- package/types/DrawerLayout/DrawerLayoutLocator.d.ts +0 -1826
- package/types/DrawerLayout/DrawerLayoutLocator.d.ts.map +0 -1
- package/types/DrawerLayout/DrawerTray/DrawerTrayLocator.d.ts +0 -428
- package/types/DrawerLayout/DrawerTray/DrawerTrayLocator.d.ts.map +0 -1
- package/types/DrawerLayout/locator.d.ts +0 -5
- package/types/DrawerLayout/locator.d.ts.map +0 -1
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
import React from 'react'
|
|
25
|
+
import { render, screen, waitFor } from '@testing-library/react'
|
|
26
|
+
import { vi } from 'vitest'
|
|
27
|
+
import '@testing-library/jest-dom'
|
|
28
|
+
|
|
29
|
+
import { DrawerContent } from '../index'
|
|
30
|
+
|
|
31
|
+
describe('<DrawerContent />', () => {
|
|
32
|
+
it('should render', async () => {
|
|
33
|
+
render(<DrawerContent label="DrawerContentTest">Hello World</DrawerContent>)
|
|
34
|
+
const drawerContent = screen.getByLabelText('DrawerContentTest')
|
|
35
|
+
|
|
36
|
+
expect(drawerContent).toBeInTheDocument()
|
|
37
|
+
expect(drawerContent).toHaveTextContent('Hello World')
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should call the content ref', async () => {
|
|
41
|
+
const contentRef = vi.fn()
|
|
42
|
+
render(
|
|
43
|
+
<DrawerContent label="DrawerContentTest" contentRef={contentRef}>
|
|
44
|
+
Hello World
|
|
45
|
+
</DrawerContent>
|
|
46
|
+
)
|
|
47
|
+
const drawerContent = screen.getByLabelText('DrawerContentTest')
|
|
48
|
+
|
|
49
|
+
expect(contentRef).toHaveBeenCalledWith(drawerContent)
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
it('should not transition on mount, just on update', async () => {
|
|
53
|
+
const { rerender } = render(
|
|
54
|
+
<DrawerContent label="DrawerContentTest">Hello World</DrawerContent>
|
|
55
|
+
)
|
|
56
|
+
const drawerContent = screen.getByLabelText('DrawerContentTest')
|
|
57
|
+
|
|
58
|
+
const styleOnMount = getComputedStyle(drawerContent)
|
|
59
|
+
expect(styleOnMount.transition).toBe('')
|
|
60
|
+
|
|
61
|
+
rerender(<DrawerContent label="test">Hello World</DrawerContent>)
|
|
62
|
+
|
|
63
|
+
await waitFor(() => {
|
|
64
|
+
const drawerContentUpdated = screen.getByLabelText('test')
|
|
65
|
+
const updatedStyle = getComputedStyle(drawerContentUpdated)
|
|
66
|
+
|
|
67
|
+
expect(updatedStyle.transition).not.toBe('')
|
|
68
|
+
})
|
|
69
|
+
})
|
|
70
|
+
})
|
|
@@ -0,0 +1,187 @@
|
|
|
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
|
+
import React from 'react'
|
|
25
|
+
import { render, screen, waitFor } from '@testing-library/react'
|
|
26
|
+
import { vi } from 'vitest'
|
|
27
|
+
import '@testing-library/jest-dom'
|
|
28
|
+
|
|
29
|
+
import { DrawerTray } from '../index'
|
|
30
|
+
import { DrawerLayoutContext } from '../../index'
|
|
31
|
+
|
|
32
|
+
describe('<DrawerTray />', () => {
|
|
33
|
+
it('should render tray content when open', async () => {
|
|
34
|
+
render(
|
|
35
|
+
<DrawerTray
|
|
36
|
+
label="DrawerTray Example"
|
|
37
|
+
open={true}
|
|
38
|
+
render={() => {
|
|
39
|
+
return 'Hello from layout tray'
|
|
40
|
+
}}
|
|
41
|
+
/>
|
|
42
|
+
)
|
|
43
|
+
const drawerTray = screen.getByLabelText('DrawerTray Example')
|
|
44
|
+
|
|
45
|
+
expect(drawerTray).toBeInTheDocument()
|
|
46
|
+
expect(drawerTray).toHaveTextContent('Hello from layout tray')
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should call the contentRef', async () => {
|
|
50
|
+
const contentRef = vi.fn()
|
|
51
|
+
render(
|
|
52
|
+
<DrawerTray
|
|
53
|
+
label="DrawerTray Example"
|
|
54
|
+
open={true}
|
|
55
|
+
contentRef={contentRef}
|
|
56
|
+
render={() => {
|
|
57
|
+
return 'Hello from layout tray'
|
|
58
|
+
}}
|
|
59
|
+
/>
|
|
60
|
+
)
|
|
61
|
+
const drawerTray = screen.getByLabelText('DrawerTray Example')
|
|
62
|
+
|
|
63
|
+
expect(contentRef).toHaveBeenCalledWith(drawerTray.parentElement)
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('should call onOpen', async () => {
|
|
67
|
+
const onOpen = vi.fn()
|
|
68
|
+
|
|
69
|
+
const { rerender } = render(
|
|
70
|
+
<DrawerTray
|
|
71
|
+
label="DrawerTray Example"
|
|
72
|
+
open={false}
|
|
73
|
+
onOpen={onOpen}
|
|
74
|
+
render={() => {
|
|
75
|
+
return 'Hello from layout tray'
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
expect(onOpen).not.toHaveBeenCalled()
|
|
81
|
+
|
|
82
|
+
// set prop open
|
|
83
|
+
rerender(
|
|
84
|
+
<DrawerTray
|
|
85
|
+
label="DrawerTray Example"
|
|
86
|
+
open={true}
|
|
87
|
+
onOpen={onOpen}
|
|
88
|
+
render={() => {
|
|
89
|
+
return 'Hello from layout tray'
|
|
90
|
+
}}
|
|
91
|
+
/>
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
await waitFor(() => {
|
|
95
|
+
expect(onOpen).toHaveBeenCalled()
|
|
96
|
+
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
it('should call onOpen when open initially', async () => {
|
|
100
|
+
const onOpen = vi.fn()
|
|
101
|
+
render(
|
|
102
|
+
<DrawerTray
|
|
103
|
+
label="DrawerTray Example"
|
|
104
|
+
open={true}
|
|
105
|
+
onOpen={onOpen}
|
|
106
|
+
render={() => {
|
|
107
|
+
return 'Hello from layout tray'
|
|
108
|
+
}}
|
|
109
|
+
/>
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
await waitFor(() => {
|
|
113
|
+
expect(onOpen).toHaveBeenCalled()
|
|
114
|
+
})
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('should call onClose', async () => {
|
|
118
|
+
const onClose = vi.fn()
|
|
119
|
+
|
|
120
|
+
const { rerender } = render(
|
|
121
|
+
<DrawerTray
|
|
122
|
+
label="DrawerTray Example"
|
|
123
|
+
open={true}
|
|
124
|
+
onClose={onClose}
|
|
125
|
+
render={() => {
|
|
126
|
+
return 'Hello from layout tray'
|
|
127
|
+
}}
|
|
128
|
+
/>
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
expect(onClose).not.toHaveBeenCalled()
|
|
132
|
+
|
|
133
|
+
// set prop open
|
|
134
|
+
rerender(
|
|
135
|
+
<DrawerTray
|
|
136
|
+
label="DrawerTray Example"
|
|
137
|
+
open={false}
|
|
138
|
+
onClose={onClose}
|
|
139
|
+
render={() => {
|
|
140
|
+
return 'Hello from layout tray'
|
|
141
|
+
}}
|
|
142
|
+
/>
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
await waitFor(() => {
|
|
146
|
+
expect(onClose).toHaveBeenCalled()
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
describe('should apply the a11y attributes', () => {
|
|
151
|
+
it("when it doesn't overlay the content", async () => {
|
|
152
|
+
render(
|
|
153
|
+
<DrawerLayoutContext.Provider value={false}>
|
|
154
|
+
<DrawerTray
|
|
155
|
+
label="a tray test"
|
|
156
|
+
open={true}
|
|
157
|
+
render={() => {
|
|
158
|
+
return 'Hello from layout tray'
|
|
159
|
+
}}
|
|
160
|
+
/>
|
|
161
|
+
</DrawerLayoutContext.Provider>
|
|
162
|
+
)
|
|
163
|
+
const drawerTray = screen.getByLabelText('a tray test')
|
|
164
|
+
|
|
165
|
+
expect(drawerTray).toBeInTheDocument()
|
|
166
|
+
expect(drawerTray).toHaveAttribute('role', 'region')
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
it('when it overlays the content', async () => {
|
|
170
|
+
render(
|
|
171
|
+
<DrawerLayoutContext.Provider value={true}>
|
|
172
|
+
<DrawerTray
|
|
173
|
+
label="a tray test"
|
|
174
|
+
open={true}
|
|
175
|
+
render={() => {
|
|
176
|
+
return 'Hello from layout tray'
|
|
177
|
+
}}
|
|
178
|
+
/>
|
|
179
|
+
</DrawerLayoutContext.Provider>
|
|
180
|
+
)
|
|
181
|
+
const drawerTray = screen.getByLabelText('a tray test')
|
|
182
|
+
|
|
183
|
+
expect(drawerTray).toBeInTheDocument()
|
|
184
|
+
expect(drawerTray).toHaveAttribute('role', 'dialog')
|
|
185
|
+
})
|
|
186
|
+
})
|
|
187
|
+
})
|
|
@@ -21,28 +21,33 @@
|
|
|
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 React from 'react'
|
|
25
|
+
import { render, screen } from '@testing-library/react'
|
|
26
|
+
import '@testing-library/jest-dom'
|
|
24
27
|
|
|
25
|
-
import
|
|
28
|
+
import DrawerLayoutFixture from '../__fixtures__/DrawerLayout.fixture'
|
|
26
29
|
|
|
27
|
-
|
|
30
|
+
describe('<DrawerLayout />', () => {
|
|
31
|
+
it('should render', () => {
|
|
32
|
+
const { container } = render(<DrawerLayoutFixture />)
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
import { DrawerTrayLocator } from './DrawerTray/DrawerTrayLocator'
|
|
34
|
+
const layout = container.querySelector('div[class$="-drawerLayout"]')
|
|
31
35
|
|
|
32
|
-
|
|
36
|
+
expect(layout).toBeInTheDocument()
|
|
37
|
+
})
|
|
33
38
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
39
|
+
it('should render a DrawerTray and DrawerContent', async () => {
|
|
40
|
+
const { container } = render(
|
|
41
|
+
<DrawerLayoutFixture open={true} layoutWidth="800px" trayWidth="250px" />
|
|
42
|
+
)
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
44
|
+
const tray = screen.getByText('Hello from tray')
|
|
45
|
+
const contentWrapper = container.querySelector(
|
|
46
|
+
'div[class$="drawerLayout__content"]'
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
expect(tray).toBeInTheDocument()
|
|
50
|
+
expect(contentWrapper).toHaveTextContent('Hello from content')
|
|
51
|
+
expect(contentWrapper).toHaveAttribute('aria-label', 'Test DrawerContent')
|
|
52
|
+
})
|
|
48
53
|
})
|
package/tsconfig.build.json
CHANGED
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
{ "path": "../ui-view/tsconfig.build.json" },
|
|
26
26
|
{ "path": "../uid/tsconfig.build.json" },
|
|
27
27
|
{ "path": "../ui-babel-preset/tsconfig.build.json" },
|
|
28
|
-
{ "path": "../ui-test-locator/tsconfig.build.json" },
|
|
29
28
|
{ "path": "../ui-themes/tsconfig.build.json" }
|
|
30
29
|
]
|
|
31
30
|
}
|