Skip to content
This repository was archived by the owner on Sep 20, 2024. It is now read-only.

Commit 5649aed

Browse files
committed
test: add CReset tests
1 parent ef24187 commit 5649aed

File tree

4 files changed

+95
-0
lines changed

4 files changed

+95
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import CReset from '../'
2+
import { mount } from '@/tests/test-utils'
3+
4+
describe('CReset.vue', () => {
5+
let wrapper
6+
7+
beforeEach(() => {
8+
wrapper = mount(CReset)
9+
})
10+
11+
it('should render correctly', () => {
12+
expect(wrapper.is(CReset)).toBe(true)
13+
expect(wrapper.isEmpty()).toBe(true)
14+
})
15+
16+
it('should have theme, colorMode, & styleConfig properties', () => {
17+
expect(wrapper.vm).toHaveProperty('theme')
18+
expect(wrapper.vm).toHaveProperty('colorMode')
19+
expect(wrapper.vm).toHaveProperty('styleConfig')
20+
wrapper.destroy()
21+
})
22+
23+
it('should have default style config', () => {
24+
expect(wrapper.vm.styleConfig).toMatchSnapshot()
25+
wrapper.destroy()
26+
})
27+
28+
it('should accept style config prop', () => {
29+
const config = (theme, original) => {
30+
original.light.color = 'black'
31+
original.light.bg = 'yellow'
32+
33+
return original
34+
}
35+
36+
wrapper.setProps({ config })
37+
38+
// extract the config prop validator function
39+
const validator = wrapper.vm.$options.props.config.validator
40+
expect(validator(config)).toBe(true)
41+
expect(validator({})).toBe(false)
42+
43+
expect(wrapper.vm.styleConfig).toMatchSnapshot()
44+
45+
wrapper.destroy()
46+
})
47+
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`CReset.vue should accept style config prop 1`] = `
4+
Object {
5+
"dark": Object {
6+
"bg": "#1A202C",
7+
"borderColor": "rgba(255, 255, 255, 0.16)",
8+
"color": "rgba(255, 255, 255, 0.92)",
9+
"placeholderColor": "rgba(255, 255, 255, 0.24)",
10+
},
11+
"light": Object {
12+
"bg": "yellow",
13+
"borderColor": "#E2E8F0",
14+
"color": "black",
15+
"placeholderColor": "#A0AEC0",
16+
},
17+
}
18+
`;
19+
20+
exports[`CReset.vue should have default style config 1`] = `
21+
Object {
22+
"dark": Object {
23+
"bg": "#1A202C",
24+
"borderColor": "rgba(255, 255, 255, 0.16)",
25+
"color": "rgba(255, 255, 255, 0.92)",
26+
"placeholderColor": "rgba(255, 255, 255, 0.24)",
27+
},
28+
"light": Object {
29+
"bg": undefined,
30+
"borderColor": "#E2E8F0",
31+
"color": "#1A202C",
32+
"placeholderColor": "#A0AEC0",
33+
},
34+
}
35+
`;

tests/test-utils/component-utils.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as vtu from '@vue/test-utils'
2+
3+
import defaultProviders from './providers-mock'
4+
5+
const mount = (component, config = {}) => {
6+
const { provide = {} } = config
7+
8+
return vtu.mount(component, { ...config, provide: defaultProviders(provide) })
9+
}
10+
11+
export * from '@vue/test-utils'
12+
export { mount }

tests/test-utils/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
export * from './component-utils'
12
export * from './test-utils'

0 commit comments

Comments
 (0)