提交 1080516f 编写于 作者: K kutyel

Increase test coverage 🐛

上级 571fce15
......@@ -4,3 +4,4 @@ npm-debug.log.*
dist
.DS_Store
bundle-stats.html
.vscode
......@@ -429,14 +429,18 @@ describe('theming', () => {
it('should not break without a ThemeProvier if it has a defaultTheme', () => {
const MyDiv = ({ theme }) => <div>{theme.color}</div>
const MyDivWithTheme = withTheme(MyDiv);
const defaultTheme = { color: 'red' }
const theme = { color: 'red' }
const newTheme = { color: 'blue' }
MyDivWithTheme.defaultProps = {
theme: defaultTheme
}
MyDivWithTheme.defaultProps = { theme }
const wrapper = mount(<MyDivWithTheme />)
expect(wrapper.find('div').text()).toBe('red')
// Change theme
wrapper.setProps({ theme: newTheme })
expect(wrapper.find('div').text()).toBe('blue')
})
})
// @flow
import determineTheme from '../determineTheme';
const theme = { color: 'red' }
const fallbackTheme = { color: 'blue' }
describe('determineTheme', () => {
it('should take precedence over ThemeProvider', () => {
expect(determineTheme({ theme }, fallbackTheme, { theme })).toEqual(theme);
})
it('should fallback to default theme', () => {
expect(determineTheme({}, fallbackTheme, { theme })).toEqual(fallbackTheme)
})
})
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册