@instructure/ui-drawer-layout 10.2.3-snapshot-7 → 10.2.3-snapshot-9
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
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.2.3-snapshot-
|
|
6
|
+
## [10.2.3-snapshot-9](https://github.com/instructure/instructure-ui/compare/v10.2.2...v10.2.3-snapshot-9) (2024-10-01)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @instructure/ui-drawer-layout
|
|
9
9
|
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var _DrawerContent, _DrawerContent2, _DrawerContent3;
|
|
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
|
+
import React from 'react';
|
|
26
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
27
|
+
import { vi } from 'vitest';
|
|
28
|
+
import '@testing-library/jest-dom';
|
|
29
|
+
import { DrawerContent } from '../index';
|
|
30
|
+
describe('<DrawerContent />', () => {
|
|
31
|
+
it('should render', async () => {
|
|
32
|
+
render(_DrawerContent || (_DrawerContent = /*#__PURE__*/React.createElement(DrawerContent, {
|
|
33
|
+
label: "DrawerContentTest"
|
|
34
|
+
}, "Hello World")));
|
|
35
|
+
const drawerContent = screen.getByLabelText('DrawerContentTest');
|
|
36
|
+
expect(drawerContent).toBeInTheDocument();
|
|
37
|
+
expect(drawerContent).toHaveTextContent('Hello World');
|
|
38
|
+
});
|
|
39
|
+
it('should call the content ref', async () => {
|
|
40
|
+
const contentRef = vi.fn();
|
|
41
|
+
render( /*#__PURE__*/React.createElement(DrawerContent, {
|
|
42
|
+
label: "DrawerContentTest",
|
|
43
|
+
contentRef: contentRef
|
|
44
|
+
}, "Hello World"));
|
|
45
|
+
const drawerContent = screen.getByLabelText('DrawerContentTest');
|
|
46
|
+
expect(contentRef).toHaveBeenCalledWith(drawerContent);
|
|
47
|
+
});
|
|
48
|
+
it('should not transition on mount, just on update', async () => {
|
|
49
|
+
const _render = render(_DrawerContent2 || (_DrawerContent2 = /*#__PURE__*/React.createElement(DrawerContent, {
|
|
50
|
+
label: "DrawerContentTest"
|
|
51
|
+
}, "Hello World"))),
|
|
52
|
+
rerender = _render.rerender;
|
|
53
|
+
const drawerContent = screen.getByLabelText('DrawerContentTest');
|
|
54
|
+
const styleOnMount = getComputedStyle(drawerContent);
|
|
55
|
+
expect(styleOnMount.transition).toBe('');
|
|
56
|
+
rerender(_DrawerContent3 || (_DrawerContent3 = /*#__PURE__*/React.createElement(DrawerContent, {
|
|
57
|
+
label: "test"
|
|
58
|
+
}, "Hello World")));
|
|
59
|
+
await waitFor(() => {
|
|
60
|
+
const drawerContentUpdated = screen.getByLabelText('test');
|
|
61
|
+
const updatedStyle = getComputedStyle(drawerContentUpdated);
|
|
62
|
+
expect(updatedStyle.transition).not.toBe('');
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
});
|
|
@@ -0,0 +1,152 @@
|
|
|
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
|
+
import { DrawerTray } from '../index';
|
|
29
|
+
import { DrawerLayoutContext } from '../../index';
|
|
30
|
+
describe('<DrawerTray />', () => {
|
|
31
|
+
it('should render tray content when open', async () => {
|
|
32
|
+
render( /*#__PURE__*/React.createElement(DrawerTray, {
|
|
33
|
+
label: "DrawerTray Example",
|
|
34
|
+
open: true,
|
|
35
|
+
render: () => {
|
|
36
|
+
return 'Hello from layout tray';
|
|
37
|
+
}
|
|
38
|
+
}));
|
|
39
|
+
const drawerTray = screen.getByLabelText('DrawerTray Example');
|
|
40
|
+
expect(drawerTray).toBeInTheDocument();
|
|
41
|
+
expect(drawerTray).toHaveTextContent('Hello from layout tray');
|
|
42
|
+
});
|
|
43
|
+
it('should call the contentRef', async () => {
|
|
44
|
+
const contentRef = vi.fn();
|
|
45
|
+
render( /*#__PURE__*/React.createElement(DrawerTray, {
|
|
46
|
+
label: "DrawerTray Example",
|
|
47
|
+
open: true,
|
|
48
|
+
contentRef: contentRef,
|
|
49
|
+
render: () => {
|
|
50
|
+
return 'Hello from layout tray';
|
|
51
|
+
}
|
|
52
|
+
}));
|
|
53
|
+
const drawerTray = screen.getByLabelText('DrawerTray Example');
|
|
54
|
+
expect(contentRef).toHaveBeenCalledWith(drawerTray.parentElement);
|
|
55
|
+
});
|
|
56
|
+
it('should call onOpen', async () => {
|
|
57
|
+
const onOpen = vi.fn();
|
|
58
|
+
const _render = render( /*#__PURE__*/React.createElement(DrawerTray, {
|
|
59
|
+
label: "DrawerTray Example",
|
|
60
|
+
open: false,
|
|
61
|
+
onOpen: onOpen,
|
|
62
|
+
render: () => {
|
|
63
|
+
return 'Hello from layout tray';
|
|
64
|
+
}
|
|
65
|
+
})),
|
|
66
|
+
rerender = _render.rerender;
|
|
67
|
+
expect(onOpen).not.toHaveBeenCalled();
|
|
68
|
+
|
|
69
|
+
// set prop open
|
|
70
|
+
rerender( /*#__PURE__*/React.createElement(DrawerTray, {
|
|
71
|
+
label: "DrawerTray Example",
|
|
72
|
+
open: true,
|
|
73
|
+
onOpen: onOpen,
|
|
74
|
+
render: () => {
|
|
75
|
+
return 'Hello from layout tray';
|
|
76
|
+
}
|
|
77
|
+
}));
|
|
78
|
+
await waitFor(() => {
|
|
79
|
+
expect(onOpen).toHaveBeenCalled();
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
it('should call onOpen when open initially', async () => {
|
|
83
|
+
const onOpen = vi.fn();
|
|
84
|
+
render( /*#__PURE__*/React.createElement(DrawerTray, {
|
|
85
|
+
label: "DrawerTray Example",
|
|
86
|
+
open: true,
|
|
87
|
+
onOpen: onOpen,
|
|
88
|
+
render: () => {
|
|
89
|
+
return 'Hello from layout tray';
|
|
90
|
+
}
|
|
91
|
+
}));
|
|
92
|
+
await waitFor(() => {
|
|
93
|
+
expect(onOpen).toHaveBeenCalled();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
it('should call onClose', async () => {
|
|
97
|
+
const onClose = vi.fn();
|
|
98
|
+
const _render2 = render( /*#__PURE__*/React.createElement(DrawerTray, {
|
|
99
|
+
label: "DrawerTray Example",
|
|
100
|
+
open: true,
|
|
101
|
+
onClose: onClose,
|
|
102
|
+
render: () => {
|
|
103
|
+
return 'Hello from layout tray';
|
|
104
|
+
}
|
|
105
|
+
})),
|
|
106
|
+
rerender = _render2.rerender;
|
|
107
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
108
|
+
|
|
109
|
+
// set prop open
|
|
110
|
+
rerender( /*#__PURE__*/React.createElement(DrawerTray, {
|
|
111
|
+
label: "DrawerTray Example",
|
|
112
|
+
open: false,
|
|
113
|
+
onClose: onClose,
|
|
114
|
+
render: () => {
|
|
115
|
+
return 'Hello from layout tray';
|
|
116
|
+
}
|
|
117
|
+
}));
|
|
118
|
+
await waitFor(() => {
|
|
119
|
+
expect(onClose).toHaveBeenCalled();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
describe('should apply the a11y attributes', () => {
|
|
123
|
+
it("when it doesn't overlay the content", async () => {
|
|
124
|
+
render( /*#__PURE__*/React.createElement(DrawerLayoutContext.Provider, {
|
|
125
|
+
value: false
|
|
126
|
+
}, /*#__PURE__*/React.createElement(DrawerTray, {
|
|
127
|
+
label: "a tray test",
|
|
128
|
+
open: true,
|
|
129
|
+
render: () => {
|
|
130
|
+
return 'Hello from layout tray';
|
|
131
|
+
}
|
|
132
|
+
})));
|
|
133
|
+
const drawerTray = screen.getByLabelText('a tray test');
|
|
134
|
+
expect(drawerTray).toBeInTheDocument();
|
|
135
|
+
expect(drawerTray).toHaveAttribute('role', 'region');
|
|
136
|
+
});
|
|
137
|
+
it('when it overlays the content', async () => {
|
|
138
|
+
render( /*#__PURE__*/React.createElement(DrawerLayoutContext.Provider, {
|
|
139
|
+
value: true
|
|
140
|
+
}, /*#__PURE__*/React.createElement(DrawerTray, {
|
|
141
|
+
label: "a tray test",
|
|
142
|
+
open: true,
|
|
143
|
+
render: () => {
|
|
144
|
+
return 'Hello from layout tray';
|
|
145
|
+
}
|
|
146
|
+
})));
|
|
147
|
+
const drawerTray = screen.getByLabelText('a tray test');
|
|
148
|
+
expect(drawerTray).toBeInTheDocument();
|
|
149
|
+
expect(drawerTray).toHaveAttribute('role', 'dialog');
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var _DrawerLayoutFixture, _DrawerLayoutFixture2;
|
|
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
|
+
import React from 'react';
|
|
26
|
+
import { render, screen } from '@testing-library/react';
|
|
27
|
+
import '@testing-library/jest-dom';
|
|
28
|
+
import DrawerLayoutFixture from '../__fixtures__/DrawerLayout.fixture';
|
|
29
|
+
describe('<DrawerLayout />', () => {
|
|
30
|
+
it('should render', () => {
|
|
31
|
+
const _render = render(_DrawerLayoutFixture || (_DrawerLayoutFixture = /*#__PURE__*/React.createElement(DrawerLayoutFixture, null))),
|
|
32
|
+
container = _render.container;
|
|
33
|
+
const layout = container.querySelector('div[class$="-drawerLayout"]');
|
|
34
|
+
expect(layout).toBeInTheDocument();
|
|
35
|
+
});
|
|
36
|
+
it('should render a DrawerTray and DrawerContent', async () => {
|
|
37
|
+
const _render2 = render(_DrawerLayoutFixture2 || (_DrawerLayoutFixture2 = /*#__PURE__*/React.createElement(DrawerLayoutFixture, {
|
|
38
|
+
open: true,
|
|
39
|
+
layoutWidth: "800px",
|
|
40
|
+
trayWidth: "250px"
|
|
41
|
+
}))),
|
|
42
|
+
container = _render2.container;
|
|
43
|
+
const tray = screen.getByText('Hello from tray');
|
|
44
|
+
const contentWrapper = container.querySelector('div[class$="drawerLayout__content"]');
|
|
45
|
+
expect(tray).toBeInTheDocument();
|
|
46
|
+
expect(contentWrapper).toHaveTextContent('Hello from content');
|
|
47
|
+
expect(contentWrapper).toHaveAttribute('aria-label', 'Test DrawerContent');
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
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 _vitest = require("vitest");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
var _index = require("../index");
|
|
9
|
+
var _DrawerContent, _DrawerContent2, _DrawerContent3;
|
|
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('<DrawerContent />', () => {
|
|
34
|
+
it('should render', async () => {
|
|
35
|
+
(0, _react2.render)(_DrawerContent || (_DrawerContent = /*#__PURE__*/_react.default.createElement(_index.DrawerContent, {
|
|
36
|
+
label: "DrawerContentTest"
|
|
37
|
+
}, "Hello World")));
|
|
38
|
+
const drawerContent = _react2.screen.getByLabelText('DrawerContentTest');
|
|
39
|
+
expect(drawerContent).toBeInTheDocument();
|
|
40
|
+
expect(drawerContent).toHaveTextContent('Hello World');
|
|
41
|
+
});
|
|
42
|
+
it('should call the content ref', async () => {
|
|
43
|
+
const contentRef = _vitest.vi.fn();
|
|
44
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DrawerContent, {
|
|
45
|
+
label: "DrawerContentTest",
|
|
46
|
+
contentRef: contentRef
|
|
47
|
+
}, "Hello World"));
|
|
48
|
+
const drawerContent = _react2.screen.getByLabelText('DrawerContentTest');
|
|
49
|
+
expect(contentRef).toHaveBeenCalledWith(drawerContent);
|
|
50
|
+
});
|
|
51
|
+
it('should not transition on mount, just on update', async () => {
|
|
52
|
+
const _render = (0, _react2.render)(_DrawerContent2 || (_DrawerContent2 = /*#__PURE__*/_react.default.createElement(_index.DrawerContent, {
|
|
53
|
+
label: "DrawerContentTest"
|
|
54
|
+
}, "Hello World"))),
|
|
55
|
+
rerender = _render.rerender;
|
|
56
|
+
const drawerContent = _react2.screen.getByLabelText('DrawerContentTest');
|
|
57
|
+
const styleOnMount = getComputedStyle(drawerContent);
|
|
58
|
+
expect(styleOnMount.transition).toBe('');
|
|
59
|
+
rerender(_DrawerContent3 || (_DrawerContent3 = /*#__PURE__*/_react.default.createElement(_index.DrawerContent, {
|
|
60
|
+
label: "test"
|
|
61
|
+
}, "Hello World")));
|
|
62
|
+
await (0, _react2.waitFor)(() => {
|
|
63
|
+
const drawerContentUpdated = _react2.screen.getByLabelText('test');
|
|
64
|
+
const updatedStyle = getComputedStyle(drawerContentUpdated);
|
|
65
|
+
expect(updatedStyle.transition).not.toBe('');
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,156 @@
|
|
|
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 _vitest = require("vitest");
|
|
7
|
+
require("@testing-library/jest-dom");
|
|
8
|
+
var _index = require("../index");
|
|
9
|
+
var _index2 = require("../../index");
|
|
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
|
+
|
|
34
|
+
describe('<DrawerTray />', () => {
|
|
35
|
+
it('should render tray content when open', async () => {
|
|
36
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
37
|
+
label: "DrawerTray Example",
|
|
38
|
+
open: true,
|
|
39
|
+
render: () => {
|
|
40
|
+
return 'Hello from layout tray';
|
|
41
|
+
}
|
|
42
|
+
}));
|
|
43
|
+
const drawerTray = _react2.screen.getByLabelText('DrawerTray Example');
|
|
44
|
+
expect(drawerTray).toBeInTheDocument();
|
|
45
|
+
expect(drawerTray).toHaveTextContent('Hello from layout tray');
|
|
46
|
+
});
|
|
47
|
+
it('should call the contentRef', async () => {
|
|
48
|
+
const contentRef = _vitest.vi.fn();
|
|
49
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
50
|
+
label: "DrawerTray Example",
|
|
51
|
+
open: true,
|
|
52
|
+
contentRef: contentRef,
|
|
53
|
+
render: () => {
|
|
54
|
+
return 'Hello from layout tray';
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
const drawerTray = _react2.screen.getByLabelText('DrawerTray Example');
|
|
58
|
+
expect(contentRef).toHaveBeenCalledWith(drawerTray.parentElement);
|
|
59
|
+
});
|
|
60
|
+
it('should call onOpen', async () => {
|
|
61
|
+
const onOpen = _vitest.vi.fn();
|
|
62
|
+
const _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
63
|
+
label: "DrawerTray Example",
|
|
64
|
+
open: false,
|
|
65
|
+
onOpen: onOpen,
|
|
66
|
+
render: () => {
|
|
67
|
+
return 'Hello from layout tray';
|
|
68
|
+
}
|
|
69
|
+
})),
|
|
70
|
+
rerender = _render.rerender;
|
|
71
|
+
expect(onOpen).not.toHaveBeenCalled();
|
|
72
|
+
|
|
73
|
+
// set prop open
|
|
74
|
+
rerender( /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
75
|
+
label: "DrawerTray Example",
|
|
76
|
+
open: true,
|
|
77
|
+
onOpen: onOpen,
|
|
78
|
+
render: () => {
|
|
79
|
+
return 'Hello from layout tray';
|
|
80
|
+
}
|
|
81
|
+
}));
|
|
82
|
+
await (0, _react2.waitFor)(() => {
|
|
83
|
+
expect(onOpen).toHaveBeenCalled();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
it('should call onOpen when open initially', async () => {
|
|
87
|
+
const onOpen = _vitest.vi.fn();
|
|
88
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
89
|
+
label: "DrawerTray Example",
|
|
90
|
+
open: true,
|
|
91
|
+
onOpen: onOpen,
|
|
92
|
+
render: () => {
|
|
93
|
+
return 'Hello from layout tray';
|
|
94
|
+
}
|
|
95
|
+
}));
|
|
96
|
+
await (0, _react2.waitFor)(() => {
|
|
97
|
+
expect(onOpen).toHaveBeenCalled();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
it('should call onClose', async () => {
|
|
101
|
+
const onClose = _vitest.vi.fn();
|
|
102
|
+
const _render2 = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
103
|
+
label: "DrawerTray Example",
|
|
104
|
+
open: true,
|
|
105
|
+
onClose: onClose,
|
|
106
|
+
render: () => {
|
|
107
|
+
return 'Hello from layout tray';
|
|
108
|
+
}
|
|
109
|
+
})),
|
|
110
|
+
rerender = _render2.rerender;
|
|
111
|
+
expect(onClose).not.toHaveBeenCalled();
|
|
112
|
+
|
|
113
|
+
// set prop open
|
|
114
|
+
rerender( /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
115
|
+
label: "DrawerTray Example",
|
|
116
|
+
open: false,
|
|
117
|
+
onClose: onClose,
|
|
118
|
+
render: () => {
|
|
119
|
+
return 'Hello from layout tray';
|
|
120
|
+
}
|
|
121
|
+
}));
|
|
122
|
+
await (0, _react2.waitFor)(() => {
|
|
123
|
+
expect(onClose).toHaveBeenCalled();
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
describe('should apply the a11y attributes', () => {
|
|
127
|
+
it("when it doesn't overlay the content", async () => {
|
|
128
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index2.DrawerLayoutContext.Provider, {
|
|
129
|
+
value: false
|
|
130
|
+
}, /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
131
|
+
label: "a tray test",
|
|
132
|
+
open: true,
|
|
133
|
+
render: () => {
|
|
134
|
+
return 'Hello from layout tray';
|
|
135
|
+
}
|
|
136
|
+
})));
|
|
137
|
+
const drawerTray = _react2.screen.getByLabelText('a tray test');
|
|
138
|
+
expect(drawerTray).toBeInTheDocument();
|
|
139
|
+
expect(drawerTray).toHaveAttribute('role', 'region');
|
|
140
|
+
});
|
|
141
|
+
it('when it overlays the content', async () => {
|
|
142
|
+
(0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index2.DrawerLayoutContext.Provider, {
|
|
143
|
+
value: true
|
|
144
|
+
}, /*#__PURE__*/_react.default.createElement(_index.DrawerTray, {
|
|
145
|
+
label: "a tray test",
|
|
146
|
+
open: true,
|
|
147
|
+
render: () => {
|
|
148
|
+
return 'Hello from layout tray';
|
|
149
|
+
}
|
|
150
|
+
})));
|
|
151
|
+
const drawerTray = _react2.screen.getByLabelText('a tray test');
|
|
152
|
+
expect(drawerTray).toBeInTheDocument();
|
|
153
|
+
expect(drawerTray).toHaveAttribute('role', 'dialog');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
});
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
require("@testing-library/jest-dom");
|
|
7
|
+
var _DrawerLayout = _interopRequireDefault(require("../__fixtures__/DrawerLayout.fixture"));
|
|
8
|
+
var _DrawerLayoutFixture, _DrawerLayoutFixture2;
|
|
9
|
+
/*
|
|
10
|
+
* The MIT License (MIT)
|
|
11
|
+
*
|
|
12
|
+
* Copyright (c) 2015 - present Instructure, Inc.
|
|
13
|
+
*
|
|
14
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
15
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
16
|
+
* in the Software without restriction, including without limitation the rights
|
|
17
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
18
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
19
|
+
* furnished to do so, subject to the following conditions:
|
|
20
|
+
*
|
|
21
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
22
|
+
* copies or substantial portions of the Software.
|
|
23
|
+
*
|
|
24
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
25
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
26
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
27
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
28
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
29
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
30
|
+
* SOFTWARE.
|
|
31
|
+
*/
|
|
32
|
+
describe('<DrawerLayout />', () => {
|
|
33
|
+
it('should render', () => {
|
|
34
|
+
const _render = (0, _react2.render)(_DrawerLayoutFixture || (_DrawerLayoutFixture = /*#__PURE__*/_react.default.createElement(_DrawerLayout.default, null))),
|
|
35
|
+
container = _render.container;
|
|
36
|
+
const layout = container.querySelector('div[class$="-drawerLayout"]');
|
|
37
|
+
expect(layout).toBeInTheDocument();
|
|
38
|
+
});
|
|
39
|
+
it('should render a DrawerTray and DrawerContent', async () => {
|
|
40
|
+
const _render2 = (0, _react2.render)(_DrawerLayoutFixture2 || (_DrawerLayoutFixture2 = /*#__PURE__*/_react.default.createElement(_DrawerLayout.default, {
|
|
41
|
+
open: true,
|
|
42
|
+
layoutWidth: "800px",
|
|
43
|
+
trayWidth: "250px"
|
|
44
|
+
}))),
|
|
45
|
+
container = _render2.container;
|
|
46
|
+
const tray = _react2.screen.getByText('Hello from tray');
|
|
47
|
+
const contentWrapper = container.querySelector('div[class$="drawerLayout__content"]');
|
|
48
|
+
expect(tray).toBeInTheDocument();
|
|
49
|
+
expect(contentWrapper).toHaveTextContent('Hello from content');
|
|
50
|
+
expect(contentWrapper).toHaveAttribute('aria-label', 'Test DrawerContent');
|
|
51
|
+
});
|
|
52
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@instructure/ui-drawer-layout",
|
|
3
|
-
"version": "10.2.3-snapshot-
|
|
3
|
+
"version": "10.2.3-snapshot-9",
|
|
4
4
|
"description": "A main-content-plus-tray layout component",
|
|
5
5
|
"author": "Instructure, Inc. Engineering and Product Design",
|
|
6
6
|
"module": "./es/index.js",
|
|
@@ -24,29 +24,31 @@
|
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@babel/runtime": "^7.24.5",
|
|
27
|
-
"@instructure/console": "10.2.3-snapshot-
|
|
28
|
-
"@instructure/debounce": "10.2.3-snapshot-
|
|
29
|
-
"@instructure/emotion": "10.2.3-snapshot-
|
|
30
|
-
"@instructure/shared-types": "10.2.3-snapshot-
|
|
31
|
-
"@instructure/ui-dialog": "10.2.3-snapshot-
|
|
32
|
-
"@instructure/ui-dom-utils": "10.2.3-snapshot-
|
|
33
|
-
"@instructure/ui-i18n": "10.2.3-snapshot-
|
|
34
|
-
"@instructure/ui-motion": "10.2.3-snapshot-
|
|
35
|
-
"@instructure/ui-portal": "10.2.3-snapshot-
|
|
36
|
-
"@instructure/ui-position": "10.2.3-snapshot-
|
|
37
|
-
"@instructure/ui-prop-types": "10.2.3-snapshot-
|
|
38
|
-
"@instructure/ui-react-utils": "10.2.3-snapshot-
|
|
39
|
-
"@instructure/ui-test-utils": "10.2.3-snapshot-
|
|
40
|
-
"@instructure/ui-testable": "10.2.3-snapshot-
|
|
41
|
-
"@instructure/ui-utils": "10.2.3-snapshot-
|
|
42
|
-
"@instructure/ui-view": "10.2.3-snapshot-
|
|
43
|
-
"@instructure/uid": "10.2.3-snapshot-
|
|
27
|
+
"@instructure/console": "10.2.3-snapshot-9",
|
|
28
|
+
"@instructure/debounce": "10.2.3-snapshot-9",
|
|
29
|
+
"@instructure/emotion": "10.2.3-snapshot-9",
|
|
30
|
+
"@instructure/shared-types": "10.2.3-snapshot-9",
|
|
31
|
+
"@instructure/ui-dialog": "10.2.3-snapshot-9",
|
|
32
|
+
"@instructure/ui-dom-utils": "10.2.3-snapshot-9",
|
|
33
|
+
"@instructure/ui-i18n": "10.2.3-snapshot-9",
|
|
34
|
+
"@instructure/ui-motion": "10.2.3-snapshot-9",
|
|
35
|
+
"@instructure/ui-portal": "10.2.3-snapshot-9",
|
|
36
|
+
"@instructure/ui-position": "10.2.3-snapshot-9",
|
|
37
|
+
"@instructure/ui-prop-types": "10.2.3-snapshot-9",
|
|
38
|
+
"@instructure/ui-react-utils": "10.2.3-snapshot-9",
|
|
39
|
+
"@instructure/ui-test-utils": "10.2.3-snapshot-9",
|
|
40
|
+
"@instructure/ui-testable": "10.2.3-snapshot-9",
|
|
41
|
+
"@instructure/ui-utils": "10.2.3-snapshot-9",
|
|
42
|
+
"@instructure/ui-view": "10.2.3-snapshot-9",
|
|
43
|
+
"@instructure/uid": "10.2.3-snapshot-9",
|
|
44
44
|
"prop-types": "^15.8.1"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@instructure/ui-babel-preset": "10.2.3-snapshot-
|
|
48
|
-
"@instructure/ui-
|
|
49
|
-
"@
|
|
47
|
+
"@instructure/ui-babel-preset": "10.2.3-snapshot-9",
|
|
48
|
+
"@instructure/ui-themes": "10.2.3-snapshot-9",
|
|
49
|
+
"@testing-library/jest-dom": "^6.4.6",
|
|
50
|
+
"@testing-library/react": "^15.0.7",
|
|
51
|
+
"vitest": "^2.0.2"
|
|
50
52
|
},
|
|
51
53
|
"peerDependencies": {
|
|
52
54
|
"react": ">=16.8 <=18"
|