/
controls.jsx
45 lines (39 loc) · 1.38 KB
/
controls.jsx
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
import React from 'react';
import { mount } from 'enzyme';
import { Loader } from 'react-cosmos-loader';
import createStateProxy from 'react-cosmos-state-proxy';
import selectedEditorFixture from '../../__fixtures__/selected-editor';
import DragHandle from '../../../DragHandle';
import ComponentPlayground from '../../';
// Vars populated in beforeEach blocks
let wrapper;
describe('Fixture editor controls', () => {
// Fixture editor is already on so the button will untoggle it
const fixtureEditorUrl = '/?component=ComponentA&fixture=foo';
beforeEach(() => {
return new Promise(resolve => {
// Mount component in order for ref and lifecycle methods to be called
wrapper = mount(
<Loader
proxies={[createStateProxy]}
component={ComponentPlayground}
fixture={selectedEditorFixture}
onComponentRef={resolve}
/>
);
});
});
it('should set untoggle URL to fixture editor button', () => {
expect(wrapper.find(`.header a[href="${fixtureEditorUrl}"]`)).toHaveLength(
1
);
});
it('should render selected fixture editor button', () => {
expect(
wrapper.find(`.header a[href="${fixtureEditorUrl}"].selectedButton`)
).toHaveLength(1);
});
it('should render DragHandle in fixture editor pane', () => {
expect(wrapper.find('.fixtureEditorPane').find(DragHandle)).toHaveLength(1);
});
});