Skip to content

Commit 299fda4

Browse files
authored
test(TransitionGroup): test for TransitionGroup (#1269)
1 parent 7ae70ea commit 299fda4

File tree

4 files changed

+555
-28
lines changed

4 files changed

+555
-28
lines changed

packages/runtime-dom/src/components/TransitionGroup.ts

+8-11
Original file line numberDiff line numberDiff line change
@@ -47,24 +47,21 @@ const TransitionGroupImpl = {
4747
const state = useTransitionState()
4848
let prevChildren: VNode[]
4949
let children: VNode[]
50-
let hasMove: boolean | null = null
5150

5251
onUpdated(() => {
5352
// children is guaranteed to exist after initial render
5453
if (!prevChildren.length) {
5554
return
5655
}
5756
const moveClass = props.moveClass || `${props.name || 'v'}-move`
58-
// Check if move transition is needed. This check is cached per-instance.
59-
hasMove =
60-
hasMove === null
61-
? (hasMove = hasCSSTransform(
62-
prevChildren[0].el as ElementWithTransition,
63-
instance.vnode.el as Node,
64-
moveClass
65-
))
66-
: hasMove
67-
if (!hasMove) {
57+
58+
if (
59+
!hasCSSTransform(
60+
prevChildren[0].el as ElementWithTransition,
61+
instance.vnode.el as Node,
62+
moveClass
63+
)
64+
) {
6865
return
6966
}
7067

packages/vue/__tests__/Transition.spec.ts

+10-16
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,21 @@ import { h, createApp, Transition } from 'vue'
55

66
describe('e2e: Transition', () => {
77
mockWarn()
8-
const { page, html, classList, isVisible } = setupPuppeteer()
8+
const {
9+
page,
10+
html,
11+
classList,
12+
isVisible,
13+
timeout,
14+
nextFrame
15+
} = setupPuppeteer()
916
const baseUrl = `file://${path.resolve(__dirname, './transition.html')}`
1017

1118
const duration = 50
1219
const buffer = 5
1320

21+
const transitionFinish = (time = duration) => timeout(time + buffer)
22+
1423
const classWhenTransitionStart = () =>
1524
page().evaluate(() => {
1625
(document.querySelector('#toggleBtn') as any)!.click()
@@ -19,21 +28,6 @@ describe('e2e: Transition', () => {
1928
})
2029
})
2130

22-
const transitionFinish = (time = duration) =>
23-
new Promise(r => {
24-
setTimeout(r, time + buffer)
25-
})
26-
27-
const nextFrame = () => {
28-
return page().evaluate(() => {
29-
return new Promise(resolve => {
30-
requestAnimationFrame(() => {
31-
requestAnimationFrame(resolve)
32-
})
33-
})
34-
})
35-
}
36-
3731
beforeEach(async () => {
3832
await page().goto(baseUrl)
3933
await page().waitFor('#app')

0 commit comments

Comments
 (0)