1 | import React from 'react';
|
2 | import {shallow, mount} from 'enzyme';
|
3 |
|
4 | import Island, {AdaptiveIsland, Content, Header} from './island';
|
5 |
|
6 | const LINE_HEIGHT = '28px';
|
7 |
|
8 | describe('Island', () => {
|
9 | const shallowIsland = params => shallow(<Island {...params}/>);
|
10 | const mountIsland = params => mount(<Island {...params}/>);
|
11 |
|
12 | it('should create Island component', () => {
|
13 | mountIsland().should.have.type(Island);
|
14 | });
|
15 |
|
16 | it('should wrap children with div', () => {
|
17 | shallowIsland().should.have.tagName('div');
|
18 | });
|
19 |
|
20 | it('should use passed className', () => {
|
21 | shallowIsland({className: 'test-class'}).should.have.className('test-class');
|
22 | });
|
23 |
|
24 | it('should join with passed data-test', () => {
|
25 | shallowIsland({['data-test']: 'foobar'}).should.have.attr('data-test', 'ring-island foobar');
|
26 | });
|
27 |
|
28 | describe('AdaptiveIsland', () => {
|
29 | it('should render AdaptiveIsland', () => {
|
30 | mount(<AdaptiveIsland/>).should.have.type(AdaptiveIsland);
|
31 | });
|
32 |
|
33 | it('should change header size if content is scrolled', () => {
|
34 | const wrapper = mount(
|
35 | <AdaptiveIsland>
|
36 | <Header/>
|
37 | <Content/>
|
38 | </AdaptiveIsland>
|
39 | );
|
40 |
|
41 | const headerNode = wrapper.find('[data-test="ring-island-header"]');
|
42 |
|
43 | wrapper.instance().onContentScroll({scrollTop: 10});
|
44 | headerNode.should.have.style('line-height', LINE_HEIGHT);
|
45 | });
|
46 | });
|
47 |
|
48 | describe('Header', () => {
|
49 | it('should render header', () => {
|
50 | mount(<Header/>).should.have.type(Header);
|
51 | });
|
52 |
|
53 | it('should change header size', () => {
|
54 | const phase = 0.75;
|
55 | const wrapper = shallow(<Header phase={phase}/>);
|
56 | wrapper.should.have.style('line-height', LINE_HEIGHT);
|
57 | });
|
58 | });
|
59 | });
|