Skip to content

Commit 846802e

Browse files
authored
test: add test case for Q21 (webfansplz#545)
1 parent 6afbf65 commit 846802e

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

questions/21-functional-component/README.md

+1-1
Large diffs are not rendered by default.

questions/21-functional-component/README.zh-CN.md

+1-1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { mount } from "@vue/test-utils"
2+
import { describe, it, expect } from "vitest"
3+
4+
import App from "./App.vue"
5+
6+
describe("functional-component", () => {
7+
it("should work", async() => {
8+
const wrapper = mount(App)
9+
const list = wrapper.findComponent({ name: "list-component" })
10+
expect(list.vm).toBeUndefined()
11+
12+
const item1 = list.findAll("li")[0]
13+
const item2 = list.findAll("li")[1]
14+
expect(item1.attributes("style")).toBe("color: red;")
15+
expect(item2.attributes("style")).toBeUndefined()
16+
17+
await item2.trigger("click")
18+
19+
expect(item1.attributes("style")).toBeUndefined()
20+
expect(item2.attributes("style")).toBe("color: red;")
21+
})
22+
})

0 commit comments

Comments
 (0)