forked from coreui/coreui-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHeader.test.js
29 lines (24 loc) · 880 Bytes
/
Header.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import expect from 'expect'
import React from 'react'
import {renderToStaticMarkup as render} from 'react-dom/server'
import { configure, mount, shallow } from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
import { spy } from 'sinon'
import CHeader from 'src/CHeader'
configure({ adapter: new Adapter() });
describe('CHeader', () => {
it('renders header with class="c-header"', () => {
expect(render(<CHeader fixed />))
.toContain('<header class="c-header"></header>')
});
it('calls componentDidMount', () => {
spy(CHeader.prototype, 'componentDidMount');
const wrapper = mount(<CHeader fixed/>);
expect(CHeader.prototype.componentDidMount.calledOnce).toEqual(true);
});
it('should call isFixed()', () => {
const isFixed = spy(CHeader.prototype, 'isFixed');
shallow(<CHeader />);
expect(isFixed.called).toBe(true);
});
})