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

Commit 0d808b3

Browse files
Merge pull request #300 from freality/creset-tests
test: add tests for Creset.vue
2 parents 88cdef7 + ab33c23 commit 0d808b3

File tree

3 files changed

+831
-1
lines changed

3 files changed

+831
-1
lines changed

packages/chakra-ui-core/src/CReset/CReset.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ const CReset = {
5151
}
5252
},
5353
props: {
54-
config: Function
54+
config: {
55+
type: Function,
56+
validator (value) {
57+
return typeof value === 'function'
58+
}
59+
}
5560
},
5661
created () {
5762
const { color, bg, borderColor, placeholderColor } = this.styleConfig[this.colorMode]
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import CReset from '../'
2+
import { render } from '@/tests/test-utils'
3+
4+
const renderComponent = (props) => {
5+
const inlineAttrs = (props && props.inlineAttrs) || ''
6+
const base = {
7+
components: { CReset },
8+
template: `<CReset data-testid="reset" ${inlineAttrs} />`,
9+
...props
10+
}
11+
return render(base)
12+
}
13+
14+
describe('CReset.vue', () => {
15+
it('should render correctly', () => {
16+
const { asFragment } = renderComponent()
17+
18+
expect(asFragment()).toMatchSnapshot()
19+
})
20+
21+
it('should inject global styles', () => {
22+
renderComponent()
23+
24+
expect(document.head).toMatchSnapshot()
25+
})
26+
27+
it('should accept config prop', () => {
28+
const inlineAttrs = ':config="cssResetConfig"'
29+
const cssResetConfig = (_, defaults) => {
30+
const { light } = defaults
31+
return {
32+
...defaults, light: { ...light, bg: 'pink', color: 'indigo' }
33+
}
34+
}
35+
36+
renderComponent({ inlineAttrs, methods: { cssResetConfig } })
37+
38+
expect(document.head).toMatchSnapshot()
39+
})
40+
})

0 commit comments

Comments
 (0)