Skip to content

Commit cf042b1

Browse files
committed
test: create missing unit tests and update existing
1 parent 96200aa commit cf042b1

39 files changed

+445
-132
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"build:es": "rollup -c --environment TARGET:esm",
6161
"lint": "vue-cli-service lint --ignore-pattern **/*spec.js",
6262
"test": "vue-cli-service test:unit",
63-
"test:coverage": "vue-cli-service test:unit --coverage --collectCoverageFrom=src/**/*.{js,vue} --collectCoverageFrom=!**/index*",
63+
"test:coverage": "vue-cli-service test:unit --coverage",
6464
"clearCache": "jest --clearCache",
6565
"release": "npm-run-all clearCache lint build test:coverage"
6666
},

src/components/breadcrumb/tests/CBreadcrumb.spec.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { mount } from '@vue/test-utils'
1+
import {
2+
mount
3+
} from '@vue/test-utils'
24
import Component from '../CBreadcrumb'
35

46
const ComponentName = 'CBreadcrumb'
@@ -19,11 +21,20 @@ const wrapper = mount(Component, {
1921
}
2022
})
2123

24+
const wrapperSlot = mount(Component, {
25+
slots: {
26+
default: 'default slot content'
27+
}
28+
})
29+
2230
describe(ComponentName, () => {
2331
it('has a name', () => {
2432
expect(Component.name).toMatch(ComponentName)
2533
})
2634
it('renders correctly', () => {
2735
expect(wrapper.element).toMatchSnapshot()
2836
})
29-
});
37+
it('renders correctly with slot content', () => {
38+
expect(wrapperSlot.element).toMatchSnapshot()
39+
})
40+
})

src/components/breadcrumb/tests/__snapshots__/CBreadcrumb.spec.js.snap

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,13 @@ exports[`CBreadcrumb renders correctly 1`] = `
4444
4545
</ol>
4646
`;
47+
48+
exports[`CBreadcrumb renders correctly with slot content 1`] = `
49+
<ol
50+
class="breadcrumb"
51+
>
52+
53+
<!---->
54+
default slot content
55+
</ol>
56+
`;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from '../CCardImg'
3+
const ComponentName = 'CCardImg'
4+
5+
const wrapper = mount(Component)
6+
const wrapperTop = mount(Component, {
7+
props: {
8+
variant: 'top'
9+
}
10+
})
11+
12+
describe(ComponentName, () => {
13+
it('has a name', () => {
14+
expect(Component.name).toMatch(ComponentName)
15+
})
16+
it('renders correctly', () => {
17+
expect(wrapper.element).toMatchSnapshot()
18+
})
19+
it('renders correctly with variant', () => {
20+
expect(wrapperTop.element).toMatchSnapshot()
21+
})
22+
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from '../CCardImgOverlay'
3+
const ComponentName = 'CCardImgOverlay'
4+
5+
const wrapper = mount(Component, {
6+
slots: {
7+
default: 'content goes here'
8+
}
9+
})
10+
11+
describe(ComponentName, () => {
12+
it('has a name', () => {
13+
expect(Component.name).toMatch(ComponentName)
14+
})
15+
it('renders correctly', () => {
16+
expect(wrapper.element).toMatchSnapshot()
17+
})
18+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from '../CCardLink'
3+
const ComponentName = 'CCardLink'
4+
const wrapper = mount(Component)
5+
6+
describe(ComponentName, () => {
7+
it('has a name', () => {
8+
expect(Component.name).toMatch(ComponentName)
9+
})
10+
it('renders correctly', () => {
11+
expect(wrapper.element).toMatchSnapshot()
12+
})
13+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from '../CCardSubtitle'
3+
const ComponentName = 'CCardSubtitle'
4+
const wrapper = mount(Component)
5+
6+
describe(ComponentName, () => {
7+
it('has a name', () => {
8+
expect(Component.name).toMatch(ComponentName)
9+
})
10+
it('renders correctly', () => {
11+
expect(wrapper.element).toMatchSnapshot()
12+
})
13+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from '../CCardText'
3+
const ComponentName = 'CCardText'
4+
const wrapper = mount(Component)
5+
6+
describe(ComponentName, () => {
7+
it('has a name', () => {
8+
expect(Component.name).toMatch(ComponentName)
9+
})
10+
it('renders correctly', () => {
11+
expect(wrapper.element).toMatchSnapshot()
12+
})
13+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from '../CCardTitle'
3+
const ComponentName = 'CCardTitle'
4+
const wrapper = mount(Component)
5+
6+
describe(ComponentName, () => {
7+
it('has a name', () => {
8+
expect(Component.name).toMatch(ComponentName)
9+
})
10+
it('renders correctly', () => {
11+
expect(wrapper.element).toMatchSnapshot()
12+
})
13+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CCardImg renders correctly 1`] = `
4+
<svg
5+
class="card-img"
6+
style="background-color: transparent;"
7+
/>
8+
`;
9+
10+
exports[`CCardImg renders correctly with variant 1`] = `
11+
<svg
12+
class="card-img-undefined"
13+
style="background-color: transparent;"
14+
/>
15+
`;

0 commit comments

Comments
 (0)