Skip to content

Commit dc588a1

Browse files
committed
chore(VDialog): update cypress tests to vitest
1 parent d605f87 commit dc588a1

File tree

2 files changed

+47
-39
lines changed

2 files changed

+47
-39
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Components
2+
import { VDialog } from '../VDialog'
3+
4+
// Utilities
5+
import { render, screen, userEvent } from '@test'
6+
import { nextTick, ref } from 'vue'
7+
8+
// Tests
9+
describe('VDialog', () => {
10+
it('should render correctly', async () => {
11+
const model = ref(false)
12+
const { element } = render(() => (
13+
<div>
14+
<VDialog v-model={ model.value } data-testid="dialog">
15+
<div data-testid="content">Content</div>
16+
</VDialog>
17+
</div>
18+
))
19+
20+
expect(screen.queryByTestId('dialog')).toBeNull()
21+
22+
model.value = true
23+
await nextTick()
24+
await expect(screen.findByTestId('dialog')).resolves.toBeVisible()
25+
await expect.element(await screen.findByTestId('content')).toBeVisible()
26+
27+
await userEvent.click(element)
28+
await expect.poll(() => model.value).toBeFalsy()
29+
await expect.poll(() => screen.queryByTestId('dialog')).toBeNull()
30+
await expect.poll(() => screen.queryByTestId('content')).toBeNull()
31+
})
32+
33+
it('should emit afterLeave', async () => {
34+
const model = ref(true)
35+
const onAfterLeave = vi.fn()
36+
const { element } = render(() => (
37+
<div>
38+
<VDialog v-model={ model.value } onAfterLeave={ onAfterLeave }>
39+
<div data-test="content">Content</div>
40+
</VDialog>
41+
</div>
42+
))
43+
44+
await userEvent.click(element)
45+
await expect.poll(() => onAfterLeave).toHaveBeenCalledTimes(1)
46+
})
47+
})

packages/vuetify/src/components/VDialog/__test__/VDialog.spec.cy.tsx

-39
This file was deleted.

0 commit comments

Comments
 (0)