Skip to content

Commit f791111

Browse files
test: switch to snapshot testing
1 parent c76c9f3 commit f791111

File tree

2 files changed

+57
-8
lines changed

2 files changed

+57
-8
lines changed

test/VueLink.spec.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ describe('VueLink', () => {
5454
expect(wrapper.isVueInstance()).toBe(false)
5555
expect(wrapper.contains(RouterLinkStub)).toBe(false)
5656

57-
expect(wrapper.html()).toBe('<a href="http://example.com/"><div>Hi</div></a>')
57+
expect(wrapper.html()).toMatchSnapshot()
5858
})
5959
it('does trigger external on https link', () => {
6060
const wrapper = mount(VueLink, {
@@ -76,7 +76,7 @@ describe('VueLink', () => {
7676
expect(wrapper.isVueInstance()).toBe(false)
7777
expect(wrapper.contains(RouterLinkStub)).toBe(false)
7878

79-
expect(wrapper.html()).toBe('<a href="https://example.com/"><div>Hi</div></a>')
79+
expect(wrapper.html()).toMatchSnapshot()
8080
})
8181
it('does trigger external on // link', () => {
8282
const wrapper = mount(VueLink, {
@@ -98,7 +98,7 @@ describe('VueLink', () => {
9898
expect(wrapper.isVueInstance()).toBe(false)
9999
expect(wrapper.contains(RouterLinkStub)).toBe(false)
100100

101-
expect(wrapper.html()).toBe('<a href="//example.com/"><div>Hi</div></a>')
101+
expect(wrapper.html()).toMatchSnapshot()
102102
})
103103
it('does trigger external on external prop set', () => {
104104
const wrapper = mount(VueLink, {
@@ -121,7 +121,7 @@ describe('VueLink', () => {
121121
expect(wrapper.isVueInstance()).toBe(false)
122122
expect(wrapper.contains(RouterLinkStub)).toBe(false)
123123

124-
expect(wrapper.html()).toBe('<a href="/far-away"><div>Hi</div></a>')
124+
expect(wrapper.html()).toMatchSnapshot()
125125
})
126126
it('does set rel correctly', () => {
127127
const wrapper = mount(VueLink, {
@@ -144,7 +144,7 @@ describe('VueLink', () => {
144144
expect(wrapper.isVueInstance()).toBe(false)
145145
expect(wrapper.contains(RouterLinkStub)).toBe(false)
146146

147-
expect(wrapper.html()).toBe('<a href="http://example.com" rel="nofollow"><div>Hi</div></a>')
147+
expect(wrapper.html()).toMatchSnapshot()
148148
})
149149
it('does set target on newTab correctly', () => {
150150
const wrapper = mount(VueLink, {
@@ -167,7 +167,7 @@ describe('VueLink', () => {
167167
expect(wrapper.isVueInstance()).toBe(false)
168168
expect(wrapper.contains(RouterLinkStub)).toBe(false)
169169

170-
expect(wrapper.html()).toBe('<a href="http://example.com" target="_blank"><div>Hi</div></a>')
170+
expect(wrapper.html()).toMatchSnapshot()
171171
})
172172
it('does set target on prop correctly', () => {
173173
const wrapper = mount(VueLink, {
@@ -190,7 +190,7 @@ describe('VueLink', () => {
190190
expect(wrapper.isVueInstance()).toBe(false)
191191
expect(wrapper.contains(RouterLinkStub)).toBe(false)
192192

193-
expect(wrapper.html()).toBe('<a href="https://example.com" target="_parent"><div>Hi</div></a>')
193+
expect(wrapper.html()).toMatchSnapshot()
194194
})
195195
it('does not bind href if unset', () => {
196196
const wrapper = mount(VueLink, {
@@ -207,7 +207,7 @@ describe('VueLink', () => {
207207
expect(wrapper.isVueInstance()).toBe(false)
208208
expect(wrapper.contains(RouterLinkStub)).toBe(false)
209209

210-
expect(wrapper.html()).toBe('<a><div>Hi</div></a>')
210+
expect(wrapper.html()).toMatchSnapshot()
211211
})
212212
})
213213
})
+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`VueLink external does not bind href if unset 1`] = `
4+
<a rel="noopener">
5+
<div>Hi</div>
6+
</a>
7+
`;
8+
9+
exports[`VueLink external does set rel correctly 1`] = `
10+
<a href="http://example.com" rel="nofollow">
11+
<div>Hi</div>
12+
</a>
13+
`;
14+
15+
exports[`VueLink external does set target on newTab correctly 1`] = `
16+
<a href="http://example.com" rel="noopener" target="_blank">
17+
<div>Hi</div>
18+
</a>
19+
`;
20+
21+
exports[`VueLink external does set target on prop correctly 1`] = `
22+
<a href="https://example.com" rel="noopener" target="_parent">
23+
<div>Hi</div>
24+
</a>
25+
`;
26+
27+
exports[`VueLink external does trigger external on // link 1`] = `
28+
<a href="//example.com/" rel="noopener">
29+
<div>Hi</div>
30+
</a>
31+
`;
32+
33+
exports[`VueLink external does trigger external on external prop set 1`] = `
34+
<a href="/far-away" rel="noopener">
35+
<div>Hi</div>
36+
</a>
37+
`;
38+
39+
exports[`VueLink external does trigger external on http link 1`] = `
40+
<a href="http://example.com/" rel="noopener">
41+
<div>Hi</div>
42+
</a>
43+
`;
44+
45+
exports[`VueLink external does trigger external on https link 1`] = `
46+
<a href="https://example.com/" rel="noopener">
47+
<div>Hi</div>
48+
</a>
49+
`;

0 commit comments

Comments
 (0)