@instructure/ui-motion 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.
@@ -1,234 +0,0 @@
1
- var _div, _div2, _ExampleComponent2, _div3, _div4, _Transition3, _Transition4, _div5, _div6, _div7, _div8, _div9, _div10, _div11;
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 { Component } from 'react';
27
- import { render, waitFor, waitForElementToBeRemoved } from '@testing-library/react';
28
- import { vi } from 'vitest';
29
- import '@testing-library/jest-dom';
30
- import { Transition } from '../index';
31
- import { getClassNames } from '../styles';
32
- import { jsx as _jsx } from "@emotion/react/jsx-runtime";
33
- const COMPONENT_TEXT = 'Component Text';
34
- const getClass = (type, phase) => {
35
- const classNames = getClassNames(type);
36
- return classNames[phase];
37
- };
38
- class ExampleComponent extends Component {
39
- render() {
40
- return _div || (_div = _jsx("div", {
41
- children: COMPONENT_TEXT
42
- }));
43
- }
44
- }
45
- ExampleComponent.displayName = "ExampleComponent";
46
- describe('<Transition />', () => {
47
- let consoleWarningMock;
48
- let consoleErrorMock;
49
- beforeEach(() => {
50
- // Mocking console to prevent test output pollution and expect for messages
51
- consoleWarningMock = vi.spyOn(console, 'warn').mockImplementation(() => {});
52
- consoleErrorMock = vi.spyOn(console, 'error').mockImplementation(() => {});
53
- });
54
- afterEach(() => {
55
- consoleWarningMock.mockRestore();
56
- consoleErrorMock.mockRestore();
57
- });
58
- const types = ['fade', 'scale', 'slide-down', 'slide-up', 'slide-left', 'slide-right'];
59
- const expectTypeClass = function (type) {
60
- var _Transition, _Transition2;
61
- it(`should correctly apply classes for '${type}' with html element`, () => {
62
- const _render = render(_Transition || (_Transition = _jsx(Transition, {
63
- type: type,
64
- in: true,
65
- children: _div2 || (_div2 = _jsx("div", {
66
- children: "hello"
67
- }))
68
- }))),
69
- getByText = _render.getByText;
70
- const element = getByText('hello');
71
- expect(element).toHaveClass(getClass(type, 'entered'));
72
- });
73
- it(`should correctly apply classes for '${type}' with Component`, () => {
74
- const _render2 = render(_Transition2 || (_Transition2 = _jsx(Transition, {
75
- type: type,
76
- in: true,
77
- children: _ExampleComponent2 || (_ExampleComponent2 = _jsx(ExampleComponent, {}))
78
- }))),
79
- getByText = _render2.getByText;
80
- const element = getByText(COMPONENT_TEXT);
81
- expect(element).toHaveClass(getClass(type, 'entered'));
82
- });
83
- };
84
- types.forEach(type => {
85
- expectTypeClass(type);
86
- });
87
- it('should correctly apply enter and exit classes', async () => {
88
- const type = 'fade';
89
- const _render3 = render(_jsx(Transition, {
90
- type: type,
91
- in: true,
92
- children: _div3 || (_div3 = _jsx("div", {
93
- children: "hello"
94
- }))
95
- })),
96
- getByText = _render3.getByText,
97
- rerender = _render3.rerender;
98
- const element = getByText('hello');
99
- expect(element).toHaveClass(getClass(type, 'entered'));
100
- rerender(_jsx(Transition, {
101
- type: type,
102
- in: false,
103
- children: _div4 || (_div4 = _jsx("div", {
104
- children: "hello"
105
- }))
106
- }));
107
- await waitFor(() => {
108
- expect(element).toHaveClass(getClass(type, 'exited'));
109
- });
110
- });
111
- it('should remove component from DOM when `unmountOnExit` is set', async () => {
112
- const _render4 = render(_Transition3 || (_Transition3 = _jsx(Transition, {
113
- type: "fade",
114
- in: true,
115
- unmountOnExit: true,
116
- children: _jsx("div", {
117
- children: "hello"
118
- })
119
- }))),
120
- getByText = _render4.getByText,
121
- rerender = _render4.rerender;
122
- expect(getByText('hello')).toBeInTheDocument();
123
- rerender(_Transition4 || (_Transition4 = _jsx(Transition, {
124
- type: "fade",
125
- in: false,
126
- unmountOnExit: true,
127
- children: _jsx("div", {
128
- children: "hello"
129
- })
130
- })));
131
- await waitForElementToBeRemoved(() => getByText('hello'));
132
- });
133
- it('should not execute enter transition with `transitionEnter` set to false', async () => {
134
- const onEntering = vi.fn();
135
- const _render5 = render(_jsx(Transition, {
136
- type: "fade",
137
- in: false,
138
- transitionEnter: true,
139
- onEntering: onEntering,
140
- children: _div5 || (_div5 = _jsx("div", {
141
- children: "hello"
142
- }))
143
- })),
144
- rerender = _render5.rerender;
145
- rerender(_jsx(Transition, {
146
- type: "fade",
147
- in: true,
148
- transitionEnter: false,
149
- onEntering: onEntering,
150
- children: _div6 || (_div6 = _jsx("div", {
151
- children: "hello"
152
- }))
153
- }));
154
- await waitFor(() => {
155
- expect(onEntering).not.toHaveBeenCalled();
156
- });
157
- });
158
- it('should not execute exit transition with `transitionExit` set to false', async () => {
159
- const onExiting = vi.fn();
160
- const _render6 = render(_jsx(Transition, {
161
- type: "fade",
162
- in: true,
163
- transitionExit: false,
164
- onExiting: onExiting,
165
- children: _div7 || (_div7 = _jsx("div", {
166
- children: "hello"
167
- }))
168
- })),
169
- rerender = _render6.rerender;
170
- rerender(_jsx(Transition, {
171
- type: "fade",
172
- in: false,
173
- transitionExit: false,
174
- onExiting: onExiting,
175
- children: _div8 || (_div8 = _jsx("div", {
176
- children: "hello"
177
- }))
178
- }));
179
- await waitFor(() => {
180
- expect(onExiting).not.toHaveBeenCalled();
181
- });
182
- });
183
- it('should correctly call enter methods', async () => {
184
- const onEnter = vi.fn();
185
- const onEntering = vi.fn();
186
- const onEntered = vi.fn();
187
- render(_jsx(Transition, {
188
- type: "fade",
189
- in: true,
190
- onEnter: onEnter,
191
- onEntering: onEntering,
192
- onEntered: onEntered,
193
- children: _div9 || (_div9 = _jsx("div", {
194
- children: "hello"
195
- }))
196
- }));
197
- await waitFor(() => {
198
- expect(onEnter).toHaveBeenCalled();
199
- expect(onEntering).toHaveBeenCalled();
200
- expect(onEntered).toHaveBeenCalled();
201
- });
202
- });
203
- it('should correctly call exit methods', async () => {
204
- const onExit = vi.fn();
205
- const onExiting = vi.fn();
206
- const onExited = vi.fn();
207
- const _render7 = render(_jsx(Transition, {
208
- type: "fade",
209
- in: true,
210
- onExit: onExit,
211
- onExiting: onExiting,
212
- onExited: onExited,
213
- children: _div10 || (_div10 = _jsx("div", {
214
- children: "hello"
215
- }))
216
- })),
217
- rerender = _render7.rerender;
218
- rerender(_jsx(Transition, {
219
- type: "fade",
220
- in: false,
221
- onExit: onExit,
222
- onExiting: onExiting,
223
- onExited: onExited,
224
- children: _div11 || (_div11 = _jsx("div", {
225
- children: "hello"
226
- }))
227
- }));
228
- await waitFor(() => {
229
- expect(onExit).toHaveBeenCalled();
230
- expect(onExiting).toHaveBeenCalled();
231
- expect(onExited).toHaveBeenCalled();
232
- });
233
- });
234
- });
@@ -1,235 +0,0 @@
1
- "use strict";
2
-
3
- var _react = require("react");
4
- var _react2 = require("@testing-library/react");
5
- var _vitest = require("vitest");
6
- require("@testing-library/jest-dom");
7
- var _index = require("../index");
8
- var _styles = require("../styles");
9
- var _jsxRuntime = require("@emotion/react/jsx-runtime");
10
- var _div, _div2, _ExampleComponent2, _div3, _div4, _Transition3, _Transition4, _div5, _div6, _div7, _div8, _div9, _div10, _div11;
11
- /*
12
- * The MIT License (MIT)
13
- *
14
- * Copyright (c) 2015 - present Instructure, Inc.
15
- *
16
- * Permission is hereby granted, free of charge, to any person obtaining a copy
17
- * of this software and associated documentation files (the "Software"), to deal
18
- * in the Software without restriction, including without limitation the rights
19
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
20
- * copies of the Software, and to permit persons to whom the Software is
21
- * furnished to do so, subject to the following conditions:
22
- *
23
- * The above copyright notice and this permission notice shall be included in all
24
- * copies or substantial portions of the Software.
25
- *
26
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
27
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
28
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
29
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
30
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
31
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32
- * SOFTWARE.
33
- */
34
- const COMPONENT_TEXT = 'Component Text';
35
- const getClass = (type, phase) => {
36
- const classNames = (0, _styles.getClassNames)(type);
37
- return classNames[phase];
38
- };
39
- class ExampleComponent extends _react.Component {
40
- render() {
41
- return _div || (_div = (0, _jsxRuntime.jsx)("div", {
42
- children: COMPONENT_TEXT
43
- }));
44
- }
45
- }
46
- ExampleComponent.displayName = "ExampleComponent";
47
- describe('<Transition />', () => {
48
- let consoleWarningMock;
49
- let consoleErrorMock;
50
- beforeEach(() => {
51
- // Mocking console to prevent test output pollution and expect for messages
52
- consoleWarningMock = _vitest.vi.spyOn(console, 'warn').mockImplementation(() => {});
53
- consoleErrorMock = _vitest.vi.spyOn(console, 'error').mockImplementation(() => {});
54
- });
55
- afterEach(() => {
56
- consoleWarningMock.mockRestore();
57
- consoleErrorMock.mockRestore();
58
- });
59
- const types = ['fade', 'scale', 'slide-down', 'slide-up', 'slide-left', 'slide-right'];
60
- const expectTypeClass = function (type) {
61
- var _Transition, _Transition2;
62
- it(`should correctly apply classes for '${type}' with html element`, () => {
63
- const _render = (0, _react2.render)(_Transition || (_Transition = (0, _jsxRuntime.jsx)(_index.Transition, {
64
- type: type,
65
- in: true,
66
- children: _div2 || (_div2 = (0, _jsxRuntime.jsx)("div", {
67
- children: "hello"
68
- }))
69
- }))),
70
- getByText = _render.getByText;
71
- const element = getByText('hello');
72
- expect(element).toHaveClass(getClass(type, 'entered'));
73
- });
74
- it(`should correctly apply classes for '${type}' with Component`, () => {
75
- const _render2 = (0, _react2.render)(_Transition2 || (_Transition2 = (0, _jsxRuntime.jsx)(_index.Transition, {
76
- type: type,
77
- in: true,
78
- children: _ExampleComponent2 || (_ExampleComponent2 = (0, _jsxRuntime.jsx)(ExampleComponent, {}))
79
- }))),
80
- getByText = _render2.getByText;
81
- const element = getByText(COMPONENT_TEXT);
82
- expect(element).toHaveClass(getClass(type, 'entered'));
83
- });
84
- };
85
- types.forEach(type => {
86
- expectTypeClass(type);
87
- });
88
- it('should correctly apply enter and exit classes', async () => {
89
- const type = 'fade';
90
- const _render3 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Transition, {
91
- type: type,
92
- in: true,
93
- children: _div3 || (_div3 = (0, _jsxRuntime.jsx)("div", {
94
- children: "hello"
95
- }))
96
- })),
97
- getByText = _render3.getByText,
98
- rerender = _render3.rerender;
99
- const element = getByText('hello');
100
- expect(element).toHaveClass(getClass(type, 'entered'));
101
- rerender((0, _jsxRuntime.jsx)(_index.Transition, {
102
- type: type,
103
- in: false,
104
- children: _div4 || (_div4 = (0, _jsxRuntime.jsx)("div", {
105
- children: "hello"
106
- }))
107
- }));
108
- await (0, _react2.waitFor)(() => {
109
- expect(element).toHaveClass(getClass(type, 'exited'));
110
- });
111
- });
112
- it('should remove component from DOM when `unmountOnExit` is set', async () => {
113
- const _render4 = (0, _react2.render)(_Transition3 || (_Transition3 = (0, _jsxRuntime.jsx)(_index.Transition, {
114
- type: "fade",
115
- in: true,
116
- unmountOnExit: true,
117
- children: (0, _jsxRuntime.jsx)("div", {
118
- children: "hello"
119
- })
120
- }))),
121
- getByText = _render4.getByText,
122
- rerender = _render4.rerender;
123
- expect(getByText('hello')).toBeInTheDocument();
124
- rerender(_Transition4 || (_Transition4 = (0, _jsxRuntime.jsx)(_index.Transition, {
125
- type: "fade",
126
- in: false,
127
- unmountOnExit: true,
128
- children: (0, _jsxRuntime.jsx)("div", {
129
- children: "hello"
130
- })
131
- })));
132
- await (0, _react2.waitForElementToBeRemoved)(() => getByText('hello'));
133
- });
134
- it('should not execute enter transition with `transitionEnter` set to false', async () => {
135
- const onEntering = _vitest.vi.fn();
136
- const _render5 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Transition, {
137
- type: "fade",
138
- in: false,
139
- transitionEnter: true,
140
- onEntering: onEntering,
141
- children: _div5 || (_div5 = (0, _jsxRuntime.jsx)("div", {
142
- children: "hello"
143
- }))
144
- })),
145
- rerender = _render5.rerender;
146
- rerender((0, _jsxRuntime.jsx)(_index.Transition, {
147
- type: "fade",
148
- in: true,
149
- transitionEnter: false,
150
- onEntering: onEntering,
151
- children: _div6 || (_div6 = (0, _jsxRuntime.jsx)("div", {
152
- children: "hello"
153
- }))
154
- }));
155
- await (0, _react2.waitFor)(() => {
156
- expect(onEntering).not.toHaveBeenCalled();
157
- });
158
- });
159
- it('should not execute exit transition with `transitionExit` set to false', async () => {
160
- const onExiting = _vitest.vi.fn();
161
- const _render6 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Transition, {
162
- type: "fade",
163
- in: true,
164
- transitionExit: false,
165
- onExiting: onExiting,
166
- children: _div7 || (_div7 = (0, _jsxRuntime.jsx)("div", {
167
- children: "hello"
168
- }))
169
- })),
170
- rerender = _render6.rerender;
171
- rerender((0, _jsxRuntime.jsx)(_index.Transition, {
172
- type: "fade",
173
- in: false,
174
- transitionExit: false,
175
- onExiting: onExiting,
176
- children: _div8 || (_div8 = (0, _jsxRuntime.jsx)("div", {
177
- children: "hello"
178
- }))
179
- }));
180
- await (0, _react2.waitFor)(() => {
181
- expect(onExiting).not.toHaveBeenCalled();
182
- });
183
- });
184
- it('should correctly call enter methods', async () => {
185
- const onEnter = _vitest.vi.fn();
186
- const onEntering = _vitest.vi.fn();
187
- const onEntered = _vitest.vi.fn();
188
- (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Transition, {
189
- type: "fade",
190
- in: true,
191
- onEnter: onEnter,
192
- onEntering: onEntering,
193
- onEntered: onEntered,
194
- children: _div9 || (_div9 = (0, _jsxRuntime.jsx)("div", {
195
- children: "hello"
196
- }))
197
- }));
198
- await (0, _react2.waitFor)(() => {
199
- expect(onEnter).toHaveBeenCalled();
200
- expect(onEntering).toHaveBeenCalled();
201
- expect(onEntered).toHaveBeenCalled();
202
- });
203
- });
204
- it('should correctly call exit methods', async () => {
205
- const onExit = _vitest.vi.fn();
206
- const onExiting = _vitest.vi.fn();
207
- const onExited = _vitest.vi.fn();
208
- const _render7 = (0, _react2.render)((0, _jsxRuntime.jsx)(_index.Transition, {
209
- type: "fade",
210
- in: true,
211
- onExit: onExit,
212
- onExiting: onExiting,
213
- onExited: onExited,
214
- children: _div10 || (_div10 = (0, _jsxRuntime.jsx)("div", {
215
- children: "hello"
216
- }))
217
- })),
218
- rerender = _render7.rerender;
219
- rerender((0, _jsxRuntime.jsx)(_index.Transition, {
220
- type: "fade",
221
- in: false,
222
- onExit: onExit,
223
- onExiting: onExiting,
224
- onExited: onExited,
225
- children: _div11 || (_div11 = (0, _jsxRuntime.jsx)("div", {
226
- children: "hello"
227
- }))
228
- }));
229
- await (0, _react2.waitFor)(() => {
230
- expect(onExit).toHaveBeenCalled();
231
- expect(onExiting).toHaveBeenCalled();
232
- expect(onExited).toHaveBeenCalled();
233
- });
234
- });
235
- });