Skip to content

Commit 2458f6b

Browse files
committed
triggering events and nextTick shorthand
1 parent 8782536 commit 2458f6b

File tree

1 file changed

+14
-13
lines changed

1 file changed

+14
-13
lines changed

tests/unit/example.spec.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ const App = {
44
data: () => ({
55
count: 0,
66
}),
7+
methods: {
8+
increment() {
9+
this.count += 1;
10+
},
11+
},
712
template: `
13+
<button @click="increment"></button>
814
<div v-if="count % 2 === 0">
915
Count: {{ count }}. Count is even.
1016
</div>
@@ -15,7 +21,7 @@ const App = {
1521
`,
1622
};
1723

18-
function factory({ data }) {
24+
function factory({ data } = { data: {} }) {
1925
return mount(App, {
2026
data() {
2127
return data;
@@ -24,21 +30,16 @@ function factory({ data }) {
2430
}
2531

2632
describe("App", () => {
27-
it("render count when odd", () => {
28-
const wrapper = factory({
29-
data: {
30-
count: 1,
31-
},
32-
});
33+
it("render count when odd", async () => {
34+
const wrapper = factory();
35+
await wrapper.find("button").trigger("click");
3336
expect(wrapper.html()).toContain("Count: 1. Count is odd");
3437
});
3538

36-
it("render count when even", () => {
37-
const wrapper = factory({
38-
data: {
39-
count: 2,
40-
},
41-
});
39+
it("render count when even", async () => {
40+
const wrapper = factory();
41+
await wrapper.find("button").trigger("click");
42+
await wrapper.find("button").trigger("click");
4243
expect(wrapper.html()).toContain("Count: 2. Count is even");
4344
});
4445
});

0 commit comments

Comments
 (0)