Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { expect } from 'chai';
- import React from 'react';
- import { mount } from 'enzyme';
- import YourComponent from './YourComponent';
- import {TableHeaderColumn} from 'material-ui/Table';
- import configureStore from 'redux-mock-store';
- import getMuiTheme from 'material-ui/styles/getMuiTheme';
- const middlewares = [];
- const mockStore = configureStore(middlewares);
- function setup() {
- const initialState = { ... };
- const store = mockStore(initialState);
- const props = { ... };
- const shallowWrapper = shallow(<YourComponent {...props} />);
- const mountWrapper = mount(<YourComponent {...props} />, {
- context: {
- muiTheme: getMuiTheme(),
- store: store
- },
- childContextTypes: {
- muiTheme: React.PropTypes.object.isRequired,
- store: React.PropTypes.object.isRequired
- }
- });
- return {
- props,
- shallowWrapper,
- mountWrapper
- }
- }
- describe("<YourComponent />", ()=> {
- it('renders 3 <TableHeaderColumn /> components', () => {
- const { mountWrapper } = setup();
- expect(wrapper.find(TableHeaderColumn)).to.have.length(3);
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement