Skip to content

Commit 66ddb88

Browse files
committed
factory functions for concise tests
1 parent ba457d8 commit 66ddb88

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

tests/unit/example.spec.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ const App = {
1717
`,
1818
};
1919

20-
test("App", () => {
21-
const wrapper = mount(App, {
22-
props: {
23-
count: 1,
24-
},
20+
function factory(props) {
21+
return mount(App, {
22+
props,
23+
});
24+
}
25+
26+
describe("App", () => {
27+
it("render count when odd", () => {
28+
const wrapper = factory({ count: 1 });
29+
expect(wrapper.html()).toContain("Count: 1. Count is odd");
30+
});
31+
32+
it("render count when even", () => {
33+
const wrapper = factory({ count: 2 });
34+
expect(wrapper.html()).toContain("Count: 2. Count is even");
2535
});
26-
expect(wrapper.html()).toContain("Count: 1");
2736
});

0 commit comments

Comments
 (0)