@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.
- package/CHANGELOG.md +1 -1
- package/package.json +9 -9
- package/tsconfig.build.tsbuildinfo +1 -1
- package/es/Transition/__new-tests__/Transition.test.js +0 -234
- package/lib/Transition/__new-tests__/Transition.test.js +0 -235
- package/src/Transition/__new-tests__/Transition.test.tsx +0 -272
- package/types/Transition/__new-tests__/Transition.test.d.ts +0 -2
- package/types/Transition/__new-tests__/Transition.test.d.ts.map +0 -1
|
@@ -1,272 +0,0 @@
|
|
|
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 { Component } from 'react'
|
|
26
|
-
import {
|
|
27
|
-
render,
|
|
28
|
-
waitFor,
|
|
29
|
-
waitForElementToBeRemoved
|
|
30
|
-
} from '@testing-library/react'
|
|
31
|
-
import { vi } from 'vitest'
|
|
32
|
-
import type { MockInstance } from 'vitest'
|
|
33
|
-
import '@testing-library/jest-dom'
|
|
34
|
-
|
|
35
|
-
import { Transition } from '../index'
|
|
36
|
-
import { getClassNames } from '../styles'
|
|
37
|
-
|
|
38
|
-
import type { TransitionStyle, TransitionType } from '../props'
|
|
39
|
-
|
|
40
|
-
const COMPONENT_TEXT = 'Component Text'
|
|
41
|
-
|
|
42
|
-
const getClass = (
|
|
43
|
-
type: TransitionType,
|
|
44
|
-
phase: keyof TransitionStyle['classNames']
|
|
45
|
-
) => {
|
|
46
|
-
const classNames = getClassNames(type)
|
|
47
|
-
return classNames[phase]
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class ExampleComponent extends Component {
|
|
51
|
-
render() {
|
|
52
|
-
return <div>{COMPONENT_TEXT}</div>
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
describe('<Transition />', () => {
|
|
57
|
-
let consoleWarningMock: ReturnType<typeof vi.spyOn>
|
|
58
|
-
let consoleErrorMock: ReturnType<typeof vi.spyOn>
|
|
59
|
-
|
|
60
|
-
beforeEach(() => {
|
|
61
|
-
// Mocking console to prevent test output pollution and expect for messages
|
|
62
|
-
consoleWarningMock = vi
|
|
63
|
-
.spyOn(console, 'warn')
|
|
64
|
-
.mockImplementation(() => {}) as MockInstance
|
|
65
|
-
consoleErrorMock = vi
|
|
66
|
-
.spyOn(console, 'error')
|
|
67
|
-
.mockImplementation(() => {}) as MockInstance
|
|
68
|
-
})
|
|
69
|
-
|
|
70
|
-
afterEach(() => {
|
|
71
|
-
consoleWarningMock.mockRestore()
|
|
72
|
-
consoleErrorMock.mockRestore()
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
const types: TransitionType[] = [
|
|
76
|
-
'fade',
|
|
77
|
-
'scale',
|
|
78
|
-
'slide-down',
|
|
79
|
-
'slide-up',
|
|
80
|
-
'slide-left',
|
|
81
|
-
'slide-right'
|
|
82
|
-
]
|
|
83
|
-
|
|
84
|
-
const expectTypeClass = function (type: TransitionType) {
|
|
85
|
-
it(`should correctly apply classes for '${type}' with html element`, () => {
|
|
86
|
-
const { getByText } = render(
|
|
87
|
-
<Transition type={type} in={true}>
|
|
88
|
-
<div>hello</div>
|
|
89
|
-
</Transition>
|
|
90
|
-
)
|
|
91
|
-
const element = getByText('hello')
|
|
92
|
-
|
|
93
|
-
expect(element).toHaveClass(getClass(type, 'entered'))
|
|
94
|
-
})
|
|
95
|
-
|
|
96
|
-
it(`should correctly apply classes for '${type}' with Component`, () => {
|
|
97
|
-
const { getByText } = render(
|
|
98
|
-
<Transition type={type} in={true}>
|
|
99
|
-
<ExampleComponent />
|
|
100
|
-
</Transition>
|
|
101
|
-
)
|
|
102
|
-
const element = getByText(COMPONENT_TEXT)
|
|
103
|
-
|
|
104
|
-
expect(element).toHaveClass(getClass(type, 'entered'))
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
types.forEach((type) => {
|
|
109
|
-
expectTypeClass(type)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it('should correctly apply enter and exit classes', async () => {
|
|
113
|
-
const type = 'fade'
|
|
114
|
-
|
|
115
|
-
const { getByText, rerender } = render(
|
|
116
|
-
<Transition type={type} in={true}>
|
|
117
|
-
<div>hello</div>
|
|
118
|
-
</Transition>
|
|
119
|
-
)
|
|
120
|
-
const element = getByText('hello')
|
|
121
|
-
|
|
122
|
-
expect(element).toHaveClass(getClass(type, 'entered'))
|
|
123
|
-
|
|
124
|
-
rerender(
|
|
125
|
-
<Transition type={type} in={false}>
|
|
126
|
-
<div>hello</div>
|
|
127
|
-
</Transition>
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
await waitFor(() => {
|
|
131
|
-
expect(element).toHaveClass(getClass(type, 'exited'))
|
|
132
|
-
})
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
it('should remove component from DOM when `unmountOnExit` is set', async () => {
|
|
136
|
-
const { getByText, rerender } = render(
|
|
137
|
-
<Transition type="fade" in={true} unmountOnExit={true}>
|
|
138
|
-
<div>hello</div>
|
|
139
|
-
</Transition>
|
|
140
|
-
)
|
|
141
|
-
|
|
142
|
-
expect(getByText('hello')).toBeInTheDocument()
|
|
143
|
-
|
|
144
|
-
rerender(
|
|
145
|
-
<Transition type="fade" in={false} unmountOnExit={true}>
|
|
146
|
-
<div>hello</div>
|
|
147
|
-
</Transition>
|
|
148
|
-
)
|
|
149
|
-
|
|
150
|
-
await waitForElementToBeRemoved(() => getByText('hello'))
|
|
151
|
-
})
|
|
152
|
-
|
|
153
|
-
it('should not execute enter transition with `transitionEnter` set to false', async () => {
|
|
154
|
-
const onEntering = vi.fn()
|
|
155
|
-
|
|
156
|
-
const { rerender } = render(
|
|
157
|
-
<Transition
|
|
158
|
-
type="fade"
|
|
159
|
-
in={false}
|
|
160
|
-
transitionEnter={true}
|
|
161
|
-
onEntering={onEntering}
|
|
162
|
-
>
|
|
163
|
-
<div>hello</div>
|
|
164
|
-
</Transition>
|
|
165
|
-
)
|
|
166
|
-
|
|
167
|
-
rerender(
|
|
168
|
-
<Transition
|
|
169
|
-
type="fade"
|
|
170
|
-
in={true}
|
|
171
|
-
transitionEnter={false}
|
|
172
|
-
onEntering={onEntering}
|
|
173
|
-
>
|
|
174
|
-
<div>hello</div>
|
|
175
|
-
</Transition>
|
|
176
|
-
)
|
|
177
|
-
|
|
178
|
-
await waitFor(() => {
|
|
179
|
-
expect(onEntering).not.toHaveBeenCalled()
|
|
180
|
-
})
|
|
181
|
-
})
|
|
182
|
-
|
|
183
|
-
it('should not execute exit transition with `transitionExit` set to false', async () => {
|
|
184
|
-
const onExiting = vi.fn()
|
|
185
|
-
|
|
186
|
-
const { rerender } = render(
|
|
187
|
-
<Transition
|
|
188
|
-
type="fade"
|
|
189
|
-
in={true}
|
|
190
|
-
transitionExit={false}
|
|
191
|
-
onExiting={onExiting}
|
|
192
|
-
>
|
|
193
|
-
<div>hello</div>
|
|
194
|
-
</Transition>
|
|
195
|
-
)
|
|
196
|
-
|
|
197
|
-
rerender(
|
|
198
|
-
<Transition
|
|
199
|
-
type="fade"
|
|
200
|
-
in={false}
|
|
201
|
-
transitionExit={false}
|
|
202
|
-
onExiting={onExiting}
|
|
203
|
-
>
|
|
204
|
-
<div>hello</div>
|
|
205
|
-
</Transition>
|
|
206
|
-
)
|
|
207
|
-
|
|
208
|
-
await waitFor(() => {
|
|
209
|
-
expect(onExiting).not.toHaveBeenCalled()
|
|
210
|
-
})
|
|
211
|
-
})
|
|
212
|
-
|
|
213
|
-
it('should correctly call enter methods', async () => {
|
|
214
|
-
const onEnter = vi.fn()
|
|
215
|
-
const onEntering = vi.fn()
|
|
216
|
-
const onEntered = vi.fn()
|
|
217
|
-
|
|
218
|
-
render(
|
|
219
|
-
<Transition
|
|
220
|
-
type="fade"
|
|
221
|
-
in={true}
|
|
222
|
-
onEnter={onEnter}
|
|
223
|
-
onEntering={onEntering}
|
|
224
|
-
onEntered={onEntered}
|
|
225
|
-
>
|
|
226
|
-
<div>hello</div>
|
|
227
|
-
</Transition>
|
|
228
|
-
)
|
|
229
|
-
|
|
230
|
-
await waitFor(() => {
|
|
231
|
-
expect(onEnter).toHaveBeenCalled()
|
|
232
|
-
expect(onEntering).toHaveBeenCalled()
|
|
233
|
-
expect(onEntered).toHaveBeenCalled()
|
|
234
|
-
})
|
|
235
|
-
})
|
|
236
|
-
|
|
237
|
-
it('should correctly call exit methods', async () => {
|
|
238
|
-
const onExit = vi.fn()
|
|
239
|
-
const onExiting = vi.fn()
|
|
240
|
-
const onExited = vi.fn()
|
|
241
|
-
|
|
242
|
-
const { rerender } = render(
|
|
243
|
-
<Transition
|
|
244
|
-
type="fade"
|
|
245
|
-
in={true}
|
|
246
|
-
onExit={onExit}
|
|
247
|
-
onExiting={onExiting}
|
|
248
|
-
onExited={onExited}
|
|
249
|
-
>
|
|
250
|
-
<div>hello</div>
|
|
251
|
-
</Transition>
|
|
252
|
-
)
|
|
253
|
-
|
|
254
|
-
rerender(
|
|
255
|
-
<Transition
|
|
256
|
-
type="fade"
|
|
257
|
-
in={false}
|
|
258
|
-
onExit={onExit}
|
|
259
|
-
onExiting={onExiting}
|
|
260
|
-
onExited={onExited}
|
|
261
|
-
>
|
|
262
|
-
<div>hello</div>
|
|
263
|
-
</Transition>
|
|
264
|
-
)
|
|
265
|
-
|
|
266
|
-
await waitFor(() => {
|
|
267
|
-
expect(onExit).toHaveBeenCalled()
|
|
268
|
-
expect(onExiting).toHaveBeenCalled()
|
|
269
|
-
expect(onExited).toHaveBeenCalled()
|
|
270
|
-
})
|
|
271
|
-
})
|
|
272
|
-
})
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Transition.test.d.ts","sourceRoot":"","sources":["../../../src/Transition/__new-tests__/Transition.test.tsx"],"names":[],"mappings":"AAgCA,OAAO,2BAA2B,CAAA"}
|