Skip to content

Commit 66da3e4

Browse files
authored
test: add test for Q323 (#2632)
1 parent 1ea185f commit 66da3e4

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { mount } from "@vue/test-utils"
2+
import { describe, it, expect } from "vitest"
3+
4+
import Button from "./Button.vue"
5+
6+
describe("prop-validation", () => {
7+
it("should have a default type prop of 'default'", () => {
8+
const wrapper = mount(Button)
9+
expect(wrapper.vm.type).toBe("default")
10+
})
11+
it("should only accept specific values for the type prop", () => {
12+
const wrapper = mount(Button, {
13+
})
14+
expect(wrapper.vm.$options.props.type.validator("invalid")).toBe(false)
15+
const validTypes = ["primary", "ghost", "dashed", "link", "text", "default"]
16+
const randomType = validTypes[Math.floor(Math.random() * validTypes.length)]
17+
expect(wrapper.vm.$options.props.type.validator(randomType)).toBe(true)
18+
})
19+
})

0 commit comments

Comments
 (0)