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

Commit 7684c34

Browse files
committed
test: add CReset config prop test
1 parent afcec39 commit 7684c34

File tree

2 files changed

+439
-12
lines changed

2 files changed

+439
-12
lines changed
Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import CReset from '../'
2-
import { render, defaultProviders } from '@/tests/test-utils'
3-
4-
const renderComponent = (options = {}) => {
5-
return render(
6-
CReset,
7-
options,
8-
() => ({ provide: defaultProviders() })
9-
)
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)
1012
}
1113

1214
describe('CReset.vue', () => {
@@ -17,10 +19,22 @@ describe('CReset.vue', () => {
1719
})
1820

1921
it('should inject global styles', () => {
20-
const { container } = renderComponent({
21-
container: document
22-
})
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 } })
2337

24-
expect(container.head).toMatchSnapshot()
38+
expect(document.head).toMatchSnapshot()
2539
})
2640
})

0 commit comments

Comments
 (0)