我正在尝试测试使用样式(withStyles())
问题是withStyles
需要有权访问主题。
这是尝试编写安装功能。
import React from 'react';
import { mount, shallow } from 'enzyme';
import {
withStyles,
createGenerateClassName,
createMuiTheme,
jssPreset,
MuiThemeProvider,
getMuiTheme
} from 'material-ui/styles';
import PropTypes from 'prop-types';
import globalThem from 'client/theme/base';
const theme = createMuiTheme(globalThem);
const { muiThemeProviderOptions } = (new MuiThemeProvider({ theme }, {})).getChildContext()
export const shallowWithStyles = node => shallow(
node,
{
context: { muiThemeProviderOptions },
}
)
export const mountWithStyles = node => mount(
node,
{
context: { muiThemeProviderOptions },
}
)