Skip to content

Commit daf0938

Browse files
committed
Fix
1 parent a9a543c commit daf0938

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/__tests__/component.test.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ import { App } from '../app'
66
import { Child } from '../child'
77
import { ChildUsual } from '../child-usual'
88

9-
import * as appStyles from '../app.css'
10-
import * as childStyles from '../child.css'
9+
import * as dummyStyles from './dummy.css'
1110

1211

1312
test('App can initialize', () => {
@@ -16,7 +15,7 @@ test('App can initialize', () => {
1615
})
1716

1817
test('App text has class', () => {
19-
const wrapper = shallowCSSModulesRenderer(App, appStyles)
18+
const wrapper = shallow(decoratedElement(App))
2019
expect(wrapper.find('#app-text').hasClass('my-style')).toBe(true)
2120
})
2221

@@ -26,7 +25,7 @@ test('Child can initialize', () => {
2625
})
2726

2827
test('Child text has class', () => {
29-
const wrapper = shallowCSSModulesRenderer(Child, childStyles)
28+
const wrapper = shallow(decoratedElement(Child))
3029
expect(wrapper.find('#child-text').hasClass('my-style')).toBe(true)
3130
})
3231

@@ -36,16 +35,12 @@ test('ChildUsual can initialize', () => {
3635
})
3736

3837
test('ChildUsual text has class', () => {
39-
const wrapper = shallowCSSModulesRenderer(ChildUsual)
38+
const wrapper = shallow(decoratedElement(ChildUsual))
4039
expect(wrapper.find('#child-usual-text').hasClass('my-style')).toBe(true)
4140
})
4241

4342

4443

45-
function shallowCSSModulesRenderer<T, U>(component: any, styles?: any): ShallowWrapper<T, U> {
46-
if (styles) {
47-
return shallow(React.createElement(CSSModules(component, styles))) as any
48-
} else {
49-
return shallow(React.createElement(component)) as any
50-
}
44+
function decoratedElement(component: typeof React.Component): React.ComponentElement<any, any> {
45+
return React.createElement(CSSModules(component, dummyStyles, { allowMultiple: true }))
5146
}

src/__tests__/dummy.css

Whitespace-only changes.

0 commit comments

Comments
 (0)