@instructure/ui-overlays 8.55.1-snapshot-6 → 8.55.1-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 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
- ## [8.55.1-snapshot-6](https://github.com/instructure/instructure-ui/compare/v8.55.0...v8.55.1-snapshot-6) (2024-04-26)
6
+ ## [8.55.1-snapshot-9](https://github.com/instructure/instructure-ui/compare/v8.55.0...v8.55.1-snapshot-9) (2024-04-30)
7
7
 
8
8
  **Note:** Version bump only for package @instructure/ui-overlays
9
9
 
@@ -0,0 +1,71 @@
1
+ var _Mask, _Mask2;
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 { render, waitFor } from '@testing-library/react';
28
+ import userEvent from '@testing-library/user-event';
29
+ import '@testing-library/jest-dom';
30
+ import { Mask } from '../index';
31
+ describe('<Mask />', () => {
32
+ it('should render', () => {
33
+ render(_Mask || (_Mask = /*#__PURE__*/React.createElement(Mask, null)));
34
+ const mask = document.querySelector("span[class$='-mask']");
35
+ expect(mask).toBeInTheDocument();
36
+ });
37
+ it('should have tabIndex -1 when onClick is provided', () => {
38
+ const onClick = jest.fn();
39
+ render( /*#__PURE__*/React.createElement(Mask, {
40
+ onClick: onClick
41
+ }));
42
+ const mask = document.querySelector("span[class$='-mask']");
43
+ expect(mask).toHaveAttribute('tabindex', '-1');
44
+ });
45
+ it('should call onClick prop when clicked', async () => {
46
+ const onClick = jest.fn();
47
+ render( /*#__PURE__*/React.createElement(Mask, {
48
+ onClick: onClick
49
+ }));
50
+ const mask = document.querySelector("span[class$='-mask']");
51
+ await userEvent.click(mask);
52
+ await waitFor(() => {
53
+ expect(onClick).toHaveBeenCalled();
54
+ });
55
+ });
56
+ it('should apply fullscreen CSS when prop is true', () => {
57
+ render(_Mask2 || (_Mask2 = /*#__PURE__*/React.createElement(Mask, {
58
+ fullscreen: true
59
+ })));
60
+ const mask = document.querySelector("span[class$='-mask']");
61
+ expect(mask).toHaveStyle('position: fixed');
62
+ });
63
+ it('should provide an elementRef', async () => {
64
+ const elementRef = jest.fn();
65
+ render( /*#__PURE__*/React.createElement(Mask, {
66
+ elementRef: elementRef
67
+ }));
68
+ const mask = document.querySelector("span[class$='-mask']");
69
+ expect(elementRef).toHaveBeenCalledWith(mask);
70
+ });
71
+ });
@@ -0,0 +1,92 @@
1
+ var _Overlay, _Overlay2;
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 { render, screen, waitFor } from '@testing-library/react';
28
+ import '@testing-library/jest-dom';
29
+ import { Overlay } from '../index';
30
+ describe('<Overlay />', () => {
31
+ it('should render nothing when closed', () => {
32
+ render(_Overlay || (_Overlay = /*#__PURE__*/React.createElement(Overlay, {
33
+ label: "Overlay Example"
34
+ })));
35
+ const overlay = screen.queryByText('Overlay Example');
36
+ expect(overlay).not.toBeInTheDocument();
37
+ });
38
+ it('should render children when open', () => {
39
+ render(_Overlay2 || (_Overlay2 = /*#__PURE__*/React.createElement(Overlay, {
40
+ open: true,
41
+ label: "Overlay Example"
42
+ }, "Hello World")));
43
+ const overlay = screen.getByRole('dialog');
44
+ expect(overlay).toHaveTextContent('Hello World');
45
+ });
46
+ it('should fire transition callback props', async () => {
47
+ const onEnter = jest.fn();
48
+ const onEntering = jest.fn();
49
+ const onEntered = jest.fn();
50
+ render( /*#__PURE__*/React.createElement(Overlay, {
51
+ open: true,
52
+ transition: "fade",
53
+ label: "Overlay Example",
54
+ onEnter: onEnter,
55
+ onEntering: onEntering,
56
+ onEntered: onEntered
57
+ }));
58
+ await waitFor(() => {
59
+ expect(onEnter).toHaveBeenCalled();
60
+ expect(onEntering).toHaveBeenCalled();
61
+ expect(onEntered).toHaveBeenCalled();
62
+ });
63
+ });
64
+ it('should support onOpen prop', async () => {
65
+ const onOpen = jest.fn();
66
+ render( /*#__PURE__*/React.createElement(Overlay, {
67
+ open: true,
68
+ label: "Overlay Example",
69
+ onOpen: onOpen
70
+ }));
71
+ await waitFor(() => {
72
+ expect(onOpen).toHaveBeenCalled();
73
+ });
74
+ });
75
+ it('should support onClose prop', async () => {
76
+ const onClose = jest.fn();
77
+ const _render = render( /*#__PURE__*/React.createElement(Overlay, {
78
+ open: true,
79
+ label: "Overlay Example",
80
+ onClose: onClose
81
+ })),
82
+ rerender = _render.rerender;
83
+ rerender( /*#__PURE__*/React.createElement(Overlay, {
84
+ label: "Overlay Example",
85
+ onClose: onClose,
86
+ open: false
87
+ }));
88
+ await waitFor(() => {
89
+ expect(onClose).toHaveBeenCalled();
90
+ });
91
+ });
92
+ });
@@ -0,0 +1,73 @@
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 _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
7
+ require("@testing-library/jest-dom");
8
+ var _index = require("../index");
9
+ var _Mask, _Mask2;
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('<Mask />', () => {
34
+ it('should render', () => {
35
+ (0, _react2.render)(_Mask || (_Mask = /*#__PURE__*/_react.default.createElement(_index.Mask, null)));
36
+ const mask = document.querySelector("span[class$='-mask']");
37
+ expect(mask).toBeInTheDocument();
38
+ });
39
+ it('should have tabIndex -1 when onClick is provided', () => {
40
+ const onClick = jest.fn();
41
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Mask, {
42
+ onClick: onClick
43
+ }));
44
+ const mask = document.querySelector("span[class$='-mask']");
45
+ expect(mask).toHaveAttribute('tabindex', '-1');
46
+ });
47
+ it('should call onClick prop when clicked', async () => {
48
+ const onClick = jest.fn();
49
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Mask, {
50
+ onClick: onClick
51
+ }));
52
+ const mask = document.querySelector("span[class$='-mask']");
53
+ await _userEvent.default.click(mask);
54
+ await (0, _react2.waitFor)(() => {
55
+ expect(onClick).toHaveBeenCalled();
56
+ });
57
+ });
58
+ it('should apply fullscreen CSS when prop is true', () => {
59
+ (0, _react2.render)(_Mask2 || (_Mask2 = /*#__PURE__*/_react.default.createElement(_index.Mask, {
60
+ fullscreen: true
61
+ })));
62
+ const mask = document.querySelector("span[class$='-mask']");
63
+ expect(mask).toHaveStyle('position: fixed');
64
+ });
65
+ it('should provide an elementRef', async () => {
66
+ const elementRef = jest.fn();
67
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Mask, {
68
+ elementRef: elementRef
69
+ }));
70
+ const mask = document.querySelector("span[class$='-mask']");
71
+ expect(elementRef).toHaveBeenCalledWith(mask);
72
+ });
73
+ });
@@ -0,0 +1,94 @@
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 _index = require("../index");
8
+ var _Overlay, _Overlay2;
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('<Overlay />', () => {
33
+ it('should render nothing when closed', () => {
34
+ (0, _react2.render)(_Overlay || (_Overlay = /*#__PURE__*/_react.default.createElement(_index.Overlay, {
35
+ label: "Overlay Example"
36
+ })));
37
+ const overlay = _react2.screen.queryByText('Overlay Example');
38
+ expect(overlay).not.toBeInTheDocument();
39
+ });
40
+ it('should render children when open', () => {
41
+ (0, _react2.render)(_Overlay2 || (_Overlay2 = /*#__PURE__*/_react.default.createElement(_index.Overlay, {
42
+ open: true,
43
+ label: "Overlay Example"
44
+ }, "Hello World")));
45
+ const overlay = _react2.screen.getByRole('dialog');
46
+ expect(overlay).toHaveTextContent('Hello World');
47
+ });
48
+ it('should fire transition callback props', async () => {
49
+ const onEnter = jest.fn();
50
+ const onEntering = jest.fn();
51
+ const onEntered = jest.fn();
52
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Overlay, {
53
+ open: true,
54
+ transition: "fade",
55
+ label: "Overlay Example",
56
+ onEnter: onEnter,
57
+ onEntering: onEntering,
58
+ onEntered: onEntered
59
+ }));
60
+ await (0, _react2.waitFor)(() => {
61
+ expect(onEnter).toHaveBeenCalled();
62
+ expect(onEntering).toHaveBeenCalled();
63
+ expect(onEntered).toHaveBeenCalled();
64
+ });
65
+ });
66
+ it('should support onOpen prop', async () => {
67
+ const onOpen = jest.fn();
68
+ (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Overlay, {
69
+ open: true,
70
+ label: "Overlay Example",
71
+ onOpen: onOpen
72
+ }));
73
+ await (0, _react2.waitFor)(() => {
74
+ expect(onOpen).toHaveBeenCalled();
75
+ });
76
+ });
77
+ it('should support onClose prop', async () => {
78
+ const onClose = jest.fn();
79
+ const _render = (0, _react2.render)( /*#__PURE__*/_react.default.createElement(_index.Overlay, {
80
+ open: true,
81
+ label: "Overlay Example",
82
+ onClose: onClose
83
+ })),
84
+ rerender = _render.rerender;
85
+ rerender( /*#__PURE__*/_react.default.createElement(_index.Overlay, {
86
+ label: "Overlay Example",
87
+ onClose: onClose,
88
+ open: false
89
+ }));
90
+ await (0, _react2.waitFor)(() => {
91
+ expect(onClose).toHaveBeenCalled();
92
+ });
93
+ });
94
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instructure/ui-overlays",
3
- "version": "8.55.1-snapshot-6",
3
+ "version": "8.55.1-snapshot-9",
4
4
  "description": "A UI component library made by Instructure Inc.",
5
5
  "author": "Instructure, Inc. Engineering and Product Design",
6
6
  "module": "./es/index.js",
@@ -23,34 +23,34 @@
23
23
  },
24
24
  "license": "MIT",
25
25
  "devDependencies": {
26
- "@instructure/ui-babel-preset": "8.55.1-snapshot-6",
27
- "@instructure/ui-test-locator": "8.55.1-snapshot-6",
28
- "@instructure/ui-test-queries": "8.55.1-snapshot-6",
29
- "@instructure/ui-test-utils": "8.55.1-snapshot-6",
30
- "@instructure/ui-themes": "8.55.1-snapshot-6",
26
+ "@instructure/ui-babel-preset": "8.55.1-snapshot-9",
27
+ "@instructure/ui-themes": "8.55.1-snapshot-9",
28
+ "@testing-library/jest-dom": "^6.1.4",
29
+ "@testing-library/react": "^14.1.2",
30
+ "@testing-library/user-event": "^14.5.1",
31
31
  "@types/no-scroll": "^2.1.0"
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.23.2",
35
- "@instructure/console": "8.55.1-snapshot-6",
36
- "@instructure/emotion": "8.55.1-snapshot-6",
37
- "@instructure/shared-types": "8.55.1-snapshot-6",
38
- "@instructure/ui-buttons": "8.55.1-snapshot-6",
39
- "@instructure/ui-dialog": "8.55.1-snapshot-6",
40
- "@instructure/ui-dom-utils": "8.55.1-snapshot-6",
41
- "@instructure/ui-focusable": "8.55.1-snapshot-6",
42
- "@instructure/ui-i18n": "8.55.1-snapshot-6",
43
- "@instructure/ui-motion": "8.55.1-snapshot-6",
44
- "@instructure/ui-popover": "8.55.1-snapshot-6",
45
- "@instructure/ui-portal": "8.55.1-snapshot-6",
46
- "@instructure/ui-position": "8.55.1-snapshot-6",
47
- "@instructure/ui-prop-types": "8.55.1-snapshot-6",
48
- "@instructure/ui-react-utils": "8.55.1-snapshot-6",
49
- "@instructure/ui-testable": "8.55.1-snapshot-6",
50
- "@instructure/ui-tooltip": "8.55.1-snapshot-6",
51
- "@instructure/ui-utils": "8.55.1-snapshot-6",
52
- "@instructure/ui-view": "8.55.1-snapshot-6",
53
- "@instructure/uid": "8.55.1-snapshot-6",
35
+ "@instructure/console": "8.55.1-snapshot-9",
36
+ "@instructure/emotion": "8.55.1-snapshot-9",
37
+ "@instructure/shared-types": "8.55.1-snapshot-9",
38
+ "@instructure/ui-buttons": "8.55.1-snapshot-9",
39
+ "@instructure/ui-dialog": "8.55.1-snapshot-9",
40
+ "@instructure/ui-dom-utils": "8.55.1-snapshot-9",
41
+ "@instructure/ui-focusable": "8.55.1-snapshot-9",
42
+ "@instructure/ui-i18n": "8.55.1-snapshot-9",
43
+ "@instructure/ui-motion": "8.55.1-snapshot-9",
44
+ "@instructure/ui-popover": "8.55.1-snapshot-9",
45
+ "@instructure/ui-portal": "8.55.1-snapshot-9",
46
+ "@instructure/ui-position": "8.55.1-snapshot-9",
47
+ "@instructure/ui-prop-types": "8.55.1-snapshot-9",
48
+ "@instructure/ui-react-utils": "8.55.1-snapshot-9",
49
+ "@instructure/ui-testable": "8.55.1-snapshot-9",
50
+ "@instructure/ui-tooltip": "8.55.1-snapshot-9",
51
+ "@instructure/ui-utils": "8.55.1-snapshot-9",
52
+ "@instructure/ui-view": "8.55.1-snapshot-9",
53
+ "@instructure/uid": "8.55.1-snapshot-9",
54
54
  "no-scroll": "^2.1.1",
55
55
  "prop-types": "^15.8.1"
56
56
  },
@@ -0,0 +1,79 @@
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, waitFor } from '@testing-library/react'
27
+ import userEvent from '@testing-library/user-event'
28
+ import '@testing-library/jest-dom'
29
+
30
+ import { Mask } from '../index'
31
+
32
+ describe('<Mask />', () => {
33
+ it('should render', () => {
34
+ render(<Mask />)
35
+
36
+ const mask = document.querySelector("span[class$='-mask']")
37
+
38
+ expect(mask).toBeInTheDocument()
39
+ })
40
+
41
+ it('should have tabIndex -1 when onClick is provided', () => {
42
+ const onClick = jest.fn()
43
+
44
+ render(<Mask onClick={onClick} />)
45
+ const mask = document.querySelector("span[class$='-mask']")
46
+
47
+ expect(mask).toHaveAttribute('tabindex', '-1')
48
+ })
49
+
50
+ it('should call onClick prop when clicked', async () => {
51
+ const onClick = jest.fn()
52
+
53
+ render(<Mask onClick={onClick} />)
54
+
55
+ const mask = document.querySelector("span[class$='-mask']")
56
+
57
+ await userEvent.click(mask!)
58
+
59
+ await waitFor(() => {
60
+ expect(onClick).toHaveBeenCalled()
61
+ })
62
+ })
63
+
64
+ it('should apply fullscreen CSS when prop is true', () => {
65
+ render(<Mask fullscreen />)
66
+ const mask = document.querySelector("span[class$='-mask']")
67
+
68
+ expect(mask).toHaveStyle('position: fixed')
69
+ })
70
+
71
+ it('should provide an elementRef', async () => {
72
+ const elementRef = jest.fn()
73
+
74
+ render(<Mask elementRef={elementRef} />)
75
+ const mask = document.querySelector("span[class$='-mask']")
76
+
77
+ expect(elementRef).toHaveBeenCalledWith(mask)
78
+ })
79
+ })
@@ -0,0 +1,96 @@
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, waitFor } from '@testing-library/react'
27
+ import '@testing-library/jest-dom'
28
+
29
+ import { Overlay } from '../index'
30
+
31
+ describe('<Overlay />', () => {
32
+ it('should render nothing when closed', () => {
33
+ render(<Overlay label="Overlay Example" />)
34
+ const overlay = screen.queryByText('Overlay Example')
35
+
36
+ expect(overlay).not.toBeInTheDocument()
37
+ })
38
+
39
+ it('should render children when open', () => {
40
+ render(
41
+ <Overlay open label="Overlay Example">
42
+ Hello World
43
+ </Overlay>
44
+ )
45
+ const overlay = screen.getByRole('dialog')
46
+
47
+ expect(overlay).toHaveTextContent('Hello World')
48
+ })
49
+
50
+ it('should fire transition callback props', async () => {
51
+ const onEnter = jest.fn()
52
+ const onEntering = jest.fn()
53
+ const onEntered = jest.fn()
54
+
55
+ render(
56
+ <Overlay
57
+ open
58
+ transition="fade"
59
+ label="Overlay Example"
60
+ onEnter={onEnter}
61
+ onEntering={onEntering}
62
+ onEntered={onEntered}
63
+ />
64
+ )
65
+
66
+ await waitFor(() => {
67
+ expect(onEnter).toHaveBeenCalled()
68
+ expect(onEntering).toHaveBeenCalled()
69
+ expect(onEntered).toHaveBeenCalled()
70
+ })
71
+ })
72
+
73
+ it('should support onOpen prop', async () => {
74
+ const onOpen = jest.fn()
75
+
76
+ render(<Overlay open label="Overlay Example" onOpen={onOpen} />)
77
+
78
+ await waitFor(() => {
79
+ expect(onOpen).toHaveBeenCalled()
80
+ })
81
+ })
82
+
83
+ it('should support onClose prop', async () => {
84
+ const onClose = jest.fn()
85
+
86
+ const { rerender } = render(
87
+ <Overlay open label="Overlay Example" onClose={onClose} />
88
+ )
89
+
90
+ rerender(<Overlay label="Overlay Example" onClose={onClose} open={false} />)
91
+
92
+ await waitFor(() => {
93
+ expect(onClose).toHaveBeenCalled()
94
+ })
95
+ })
96
+ })
@@ -8,9 +8,6 @@
8
8
  "include": ["src"],
9
9
  "references": [
10
10
  { "path": "../ui-babel-preset/tsconfig.build.json" },
11
- { "path": "../ui-test-locator/tsconfig.build.json" },
12
- { "path": "../ui-test-queries/tsconfig.build.json" },
13
- { "path": "../ui-test-utils/tsconfig.build.json" },
14
11
  { "path": "../ui-themes/tsconfig.build.json" },
15
12
  { "path": "../console/tsconfig.build.json" },
16
13
  { "path": "../emotion/tsconfig.build.json" },