Skip to content

Commit 930d9a6

Browse files
authored
test: add test case for Q218 (#597)
1 parent 7e05049 commit 930d9a6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { mount } from "@vue/test-utils"
2+
import { describe, it, expect } from "vitest"
3+
4+
import MyButton from "./MyButton"
5+
6+
describe("Render function h()", () => {
7+
it("renders a 'MyButton'", () => {
8+
const wrapper = mount(MyButton)
9+
expect(wrapper.element.tagName.toLocaleLowerCase()).toBe('button')
10+
})
11+
12+
it("disabled", async () => {
13+
const wrapper = mount(MyButton, {
14+
props: {
15+
disabled: true
16+
}
17+
})
18+
expect(wrapper.find('button').attributes()).toBeDefined()
19+
20+
await wrapper.trigger('click')
21+
expect(wrapper.emitted('click')).toBeUndefined()
22+
})
23+
24+
it("slot", () => {
25+
const wrapper = mount(MyButton, {
26+
slots: {
27+
default: 'my button'
28+
}
29+
})
30+
expect(wrapper.text()).toBe('my button')
31+
})
32+
33+
it('custom click defined', () => {
34+
const wrapper = mount(MyButton)
35+
wrapper.trigger('click')
36+
expect(wrapper.emitted().customClick || wrapper.emitted()['custom-click']).toBeDefined()
37+
})
38+
})

0 commit comments

Comments
 (0)