Commit 8f6672d0 by bert

学习单元测试

parent 90685be1
import React from 'react'; // required to get test to work. we can get around this later with more configuration
import { shallow } from 'enzyme'; // method from enzyme which allows us to do shallow render
import Root from '../../views/Demo/Root'; // import our soon to be component
describe('(Container) Root', () => {
it('renders as a <div>', () => {
const wrapper = shallow(<Root />);
expect(wrapper.type()).to.eql('div');
});
it('has style with height 100%', () => {
const wrapper = shallow(<Root />);
const expectedStyles = {
height: '100%',
background: '#333'
}
expect(wrapper.prop('style')).to.eql(expectedStyles);
});
it('contains a header explaining the app', () => {
const wrapper = shallow(<Root />);
expect(wrapper.find('.welcome-header')).to.have.length(1);
});
});
\ No newline at end of file
import { expect } from 'chai';
describe('hello world', () => {
it('works!', () => {
expect(true).to.be.true;
});
});
\ No newline at end of file
import { expect } from 'chai';
import sinon from 'sinon';
global.expect = expect;
global.sinon = sinon;
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment