8000 test: Added CCard tests. · rmeltonmi/coreui-vue@f94a346 · GitHub
[go: up one dir, main page]

Skip to content

Commit f94a346

Browse files
committed
test: Added CCard tests.
1 parent 949362e commit f94a346

12 files changed

+262
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from "../CCard";
3+
const ComponentName = 'CCard'
4+
5+
const wrapper = mount(Component, {
6+
context: {
7+
props: {
8+
align: 'left',
9+
variant: 'success',
10+
textVariant: 'white',
11+
borderVariant: 'solid',
12+
header: 'header',
13+
footer: 'footer',
14+
body: 'body'
15+
}
16+
}
17+
})
18+
const slotWrapper = mount(Component, {
19+
context: {
20+
props: {
21+
align: 'left',
22+
variant: 'success',
23+
textVariant: 'white',
24+
borderVariant: 'solid',
25+
header: 'header',
26+
footer: 'footer',
27+
body: 'body'
28+
}
29+
},
30+
slots: {
31+
header: 'this should overwrite header<br>',
32+
default: 'this should overwrite body<br>',
33+
footer: 'this should overwrite footer'
34+
}
35+
})
36+
37+
describe(ComponentName, () => {
38+
it('has a name', () => {
39+
expect(Component.name).toMatch(ComponentName)
40+
})
41+
it('renders correctly', () => {
42+
expect(wrapper.element).toMatchSnapshot()
43+
})
44+
it('renders correctly with slots', () => {
45+
expect(slotWrapper.element).toMatchSnapshot()
46+
})
47+
});
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from "../CCardBody";
3+
4+
const ComponentName = 'CCardBody'
5+
const wrapper = mount(Component, {
6+
context: {
7+
props: {
8+
align: 'left',
9+
variant: 'primary',
10+
textVariant: 'white',
11+
borderVariant: 'solid',
12+
title: 'title',
13+
subtitle: 'subtitle'
14+
}
15+
}
16+
})
17+
18+
describe(ComponentName, () => {
19+
it('has a name', () => {
20+
expect(Component.name).toMatch(ComponentName)
21+
})
22+
it('renders correctly', () => {
23+
expect(wrapper.element).toMatchSnapshot()
24+
})
25+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from "../CCardFooter";
3+
4+
const ComponentName = 'CCardFooter'
5+
const wrapper = mount(Component, {
6+
context: {
7+
props: {
8+
align: 'left',
9+
variant: 'primary',
10+
textVariant: 'white',
11+
borderVariant: 'solid'
12+
}
13+
},
14+
slots: {
15+
default: 'content goes here'
16+
}
17+
})
18+
19+
describe(ComponentName, () => {
20+
it('has a name', () => {
21+
expect(Component.name).toMatch(ComponentName)
22+
})
23+
it('renders correctly', () => {
24+
expect(wrapper.element).toMatchSnapshot()
25+
})
26+
});
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from "../CCardGroup";
3+
const ComponentName = 'CCardGroup'
4+
const wrapper = mount(Component, {
5+
context: {
6+
props: {
7+
deck: true,
8+
column: true,
9+
tag: 'p'
10+
}
11+
},
12+
slots: {
13+
default: 'content goes here'
14+
}
15+
})
16+
17+
describe(ComponentName, () => {
18+
it('has a name', () => {
19+
expect(Component.name).toMatch(ComponentName)
20+
})
21+
it('renders correctly', () => {
22+
expect(wrapper.element).toMatchSnapshot()
23+
})
24+
});
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from "../CCardHeader";
3+
const ComponentName = 'CCardHeader'
4+
const wrapper = mount(Component, {
5+
context: {
6+
props: {
7+
header: 'header',
8+
align: 'left',
9+
variant: 'primary',
10+
textVariant: 'white',
11+
borderVariant: 'solid'
12+
}
13+
},
14+
slots: {
15+
default: 'content goes here'
16+
}
17+
})
18+
19+
describe(ComponentName, () => {
20+
it('has a name', () => {
21+
expect(Component.name).toMatch(ComponentName)
22+
})
23+
it('renders correctly', () => {
24+
expect(wrapper.element).toMatchSnapshot()
25+
})
26+
});
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { mount } from '@vue/test-utils'
2+
import Component from "../CCardImg";
3+
const ComponentName = 'CCardImg'
4+
const wrapper = mount(Component, {
5+
context: {
6+
props: {
7+
src: 'some_src'
8+
}
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+
});
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CCard renders correctly 1`] = `
4+
<div
5+
class="card text-left bg-success border-solid text-white"
6+
>
7+
<div
8+
class="card-header"
9+
>
10+
header
11+
</div>
12+
<div
13+
class="card-body"
14+
>
15+
<!---->
16+
<!---->
17+
body
18+
</div>
19+
<div
20+
class="card-footer"
21+
>
22+
footer
23+
</div>
24+
</div>
25+
`;
26+
27+
exports[`CCard renders correctly with slots 1`] = `
28+
<div
29+
class="card text-left bg-success border-solid text-white"
30+
>
31+
this should overwrite header
32+
<br />
33+
this should overwrite body
34+
<br />
35+
this should overwrite footer
36+
</div>
37+
`;
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CCardBody renders correctly 1`] = `
4+
<div
5+
class="card-body bg-primary border-solid text-white"
6+
>
7+
<h4
8+
class="card-title"
9+
>
10+
title
11+
</h4>
12+
<h6
13+
class="card-subtitle mb-2 text-muted"
14+
>
15+
subtitle
16+
</h6>
17+
</div>
18+
`;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CCardFooter renders correctly 1`] = `
4+
<div
5+
class="card-footer text-left bg-primary border-solid text-white"
6+
>
7+
<template>
8+
content goes here
9+
</template>
10+
</div>
11+
`;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CCardGroup renders correctly 1`] = `
4+
<p
5+
class="card-deck"
6+
>
7+
<template>
8+
content goes here
9+
</template>
10+
</p>
11+
`;

0 commit comments

Comments
 (0)
0