Skip to content

Commit 8782536

Browse files
committed
mounting with data
1 parent e11f79a commit 8782536

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

tests/unit/example.spec.js

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@ import { mount } from "@vue/test-utils";
22

33
const App = {
44
data: () => ({
5-
msg: "Hello",
5+
count: 0,
66
}),
7-
props: {
8-
count: {
9-
type: Number,
10-
},
11-
},
127
template: `
138
<div v-if="count % 2 === 0">
149
Count: {{ count }}. Count is even.
@@ -20,21 +15,30 @@ const App = {
2015
`,
2116
};
2217

23-
function factory(props) {
18+
function factory({ data }) {
2419
return mount(App, {
25-
props,
20+
data() {
21+
return data;
22+
},
2623
});
2724
}
2825

2926
describe("App", () => {
3027
it("render count when odd", () => {
31-
const wrapper = factory({ count: 1 });
32-
console.log(wrapper.vm);
28+
const wrapper = factory({
29+
data: {
30+
count: 1,
31+
},
32+
});
3333
expect(wrapper.html()).toContain("Count: 1. Count is odd");
3434
});
3535

3636
it("render count when even", () => {
37-
const wrapper = factory({ count: 2 });
37+
const wrapper = factory({
38+
data: {
39+
count: 2,
40+
},
41+
});
3842
expect(wrapper.html()).toContain("Count: 2. Count is even");
3943
});
4044
});

0 commit comments

Comments
 (0)