This repository was archived by the owner on Aug 27, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathheader-connector-test.js
More file actions
62 lines (58 loc) · 2.7 KB
/
header-connector-test.js
File metadata and controls
62 lines (58 loc) · 2.7 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import React from 'react';
import { mount, render } from 'enzyme';
import { compose } from 'redux'
import {connect as connectToHeader} from '../header';
import headerReducer from '../../header/header-reducer';
import {Provider as StoreProvider} from 'react-redux';
import builder from '../../store/create-store';
const store = builder({dataset:headerReducer}, [], [DevTools.instrument()]);
const LeftComponent = () => <div>left</div>
const RightComponent = () => <div>right</div>
const SummaryComponent = () => <div>summary</div>
const ExpandedComponent = () => <div>expanded</div>
const actions = {primary: [{action: () => console.log('Primaire'), label: 'Primaire', icon: 'home'}], secondary: [{action: () => console.log('secondary'), label: 'Secondaire', icon: 'home'}]};
// connectToHeader({
// actions: {primary: [{action: () => console.log('Primaire'), label: 'Primaire', icon: 'home'}], secondary: [{action: () => console.log('secondary'), label: 'Secondaire', icon: 'home'}]},
// ExpandedHeaderComponent: ExpandedUserHeader,
// SummaryHeaderComponent: SummaryUserHeader,
// LeftHeaderComponent: () => (<div>Left</div>),
// RightHeaderComponent: () => (<div>Right</div>),
// //triggerScrollPosition: 0
// })
describe('ConnectedToHeaderComponent(...)', () => {
describe('when mounted', () => {
describe.only('with no props', () => {
let capturedProps;
const ComponentToConnect = (props) => {
capturedProps = props;
return (
<div>component</div>
);
}
const WrappedComponentToConnected = () => {
<StoreProvider store={store}>
<ComponentToConnect/>
</StoreProvider>
}
const headerProps = {};
const ConnectedComponent = compose(connectToHeader(headerProps))(ComponentToConnect);
const wrapper = mount(<WrappedComponentToConnected />);
console.log(wrapper);
it('should display the header without components', () => {
const header = wrapper.find('header[data-focus="header"]');
expect(rootNode).to.exist;
const headerNotExpanded = wrapper.find('header[data-focus="header"][data-is-expanded="false"]');
expect(rootNode).to.exist;
});
});
describe('with actions', () => {
const headerProps = {
actions: actions
};
const ConnectedComponent = compose(connectToHeader(headerProps))(ComponentToConnect);
const wrapper = mount(ConnectedComponent());
it('the header should exist', () => {
});
});
});
});