Skip to content

Commit 4795af4

Browse files
committed
- Enrich the test cases
1 parent 199239f commit 4795af4

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

tests/unmount.spec.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,46 @@
1+
import { defineComponent } from 'vue'
2+
13
import { mount } from '../src'
24

35
const AXIOM = 'Rem is the best girl'
46

57
describe('Unmount', () => {
68
it('works on single root component', () => {
9+
const errorHandler = jest.fn()
710
const Component = {
811
template: `
912
<div>${AXIOM}</div>
10-
`,
11-
onErrorCaptured(err: Error) {
12-
throw err
13-
}
13+
`
1414
}
15-
const wrapper = mount(Component)
16-
expect(() => wrapper.unmount()).not.toThrowError()
15+
const wrapper = mount(Component, {
16+
props: {},
17+
global: {
18+
config: {
19+
errorHandler
20+
}
21+
}
22+
} as any) // The type checking keeps complaning about unmatched type which might be a bug
23+
wrapper.unmount()
24+
expect(errorHandler).not.toHaveBeenCalled()
1725
})
1826

1927
it('works on multi-root component', () => {
20-
const Component = {
28+
const errorHandler = jest.fn()
29+
const Component = defineComponent({
2130
template: `
2231
<div>${AXIOM}</div>
2332
<div>${AXIOM}</div>
24-
`,
25-
onErrorCaptured(err: Error) {
26-
throw err
33+
`
34+
})
35+
const wrapper = mount(Component, {
36+
props: {},
37+
global: {
38+
config: {
39+
errorHandler
40+
}
2741
}
28-
}
29-
const wrapper = mount(Component)
42+
} as any)
3043
wrapper.unmount()
44+
expect(errorHandler).not.toHaveBeenCalled()
3145
})
3246
})

0 commit comments

Comments
 (0)