如何使用Jest测试材质用户界面样式的覆盖率100%

时间:2019-03-26 01:38:21

标签: reactjs unit-testing jestjs material-ui react-with-styles

我正在为容器编写单元测试,并且希望覆盖率达到100%。但是,仍然有一项声明没有涵盖。

Here is my report

Index.js

const styles = theme => ({
  BookContainer: {
    backgroundColor: '#FAFAFA',
    boxShadow:
      'rgba(0, 0, 0, 0.12) 0px 1px 6px, rgba(0, 0, 0, 0.12) 0px 1px 4px',
  },
...

我开玩笑的测试:

    import BookTheme from 'components/BookTheme';
    import BookTitle from 'components/BookTitle';

    test('should render div tag for default case', () => {
      const muiTheme = createMuiTheme(BookTheme);
      const defaultFunc = () => {};
      const defaultClasses = {};
      const renderedComponent = shallow(
        <BookContainer
          classes={defaultClasses}
          resetKeyword={defaultFunc}
          theme={muiTheme}
        />,
      );
      expect(renderedComponent.find(BookTitle).length).toEqual(1);
    });

在这个测试案例中,我如何获得100%的覆盖率?

0 个答案:

没有答案