Skip to content

Commit f13968d

Browse files
committed
test: move unmount() to finally block
1 parent 05dcb21 commit f13968d

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

test/nuxt/components/CodeFileTree.spec.ts

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,31 @@ async function mountCodeFileTree() {
6161
describe('CodeFileTree', () => {
6262
it('expands and collapses a directory when clicked', async () => {
6363
const wrapper = await mountCodeFileTree()
64+
try {
65+
await vi.waitFor(() => {
66+
expect(wrapper.text()).toContain('constants.d.ts')
67+
expect(wrapper.text()).not.toContain('common.d.ts')
68+
})
6469

65-
await vi.waitFor(() => {
66-
expect(wrapper.text()).toContain('constants.d.ts')
67-
expect(wrapper.text()).not.toContain('common.d.ts')
68-
})
70+
const coreButton = findDirButton(wrapper, 'core')
71+
expect(coreButton).toBeDefined()
72+
await coreButton!.trigger('click')
6973

70-
const coreButton = findDirButton(wrapper, 'core')
71-
expect(coreButton).toBeDefined()
72-
await coreButton!.trigger('click')
74+
await vi.waitFor(() => {
75+
expect(wrapper.text()).not.toContain('constants.d.ts')
76+
expect(wrapper.text()).not.toContain('common.d.ts')
77+
})
7378

74-
await vi.waitFor(() => {
75-
expect(wrapper.text()).not.toContain('constants.d.ts')
76-
expect(wrapper.text()).not.toContain('common.d.ts')
77-
})
79+
const typesButton = findDirButton(wrapper, 'types')
80+
expect(typesButton).toBeDefined()
81+
await typesButton!.trigger('click')
7882

79-
const typesButton = findDirButton(wrapper, 'types')
80-
expect(typesButton).toBeDefined()
81-
await typesButton!.trigger('click')
82-
83-
await vi.waitFor(() => {
84-
expect(wrapper.text()).toContain('common.d.ts')
85-
expect(wrapper.text()).not.toContain('constants.d.ts')
86-
})
87-
88-
wrapper.unmount()
83+
await vi.waitFor(() => {
84+
expect(wrapper.text()).toContain('common.d.ts')
85+
expect(wrapper.text()).not.toContain('constants.d.ts')
86+
})
87+
} finally {
88+
wrapper.unmount()
89+
}
8990
})
9091
})

0 commit comments

Comments
 (0)