|
1 | | -import expect from 'expect' |
2 | | -import React from 'react' |
3 | | -import {render, unmountComponentAtNode} from 'react-dom' |
| 1 | +import React from 'react'; |
| 2 | +import expect, {spyOn, createSpy} from 'expect'; |
| 3 | +import { mount, shallow } from 'enzyme'; |
4 | 4 |
|
5 | | -import Component from 'src/' |
| 5 | +import Component from 'src/'; |
6 | 6 |
|
7 | | -describe('Component', () => { |
8 | | - let node |
| 7 | +describe('<Component />', () => { |
| 8 | + const sequence = 'ctcgatgctagtcgatgctagtcgtagcta'; |
9 | 9 |
|
10 | | - beforeEach(() => { |
11 | | - node = document.createElement('div') |
12 | | - }) |
| 10 | + let parent = document.createElement('div'); |
| 11 | + parent.id = 'test'; |
13 | 12 |
|
14 | | - afterEach(() => { |
15 | | - unmountComponentAtNode(node) |
16 | | - }) |
| 13 | + beforeEach(() => { |
| 14 | + document.body.appendChild(parent); |
| 15 | + }); |
| 16 | + |
| 17 | + afterEach(() => { |
| 18 | + document.body.removeChild(parent); |
| 19 | + }); |
| 20 | + |
| 21 | + it('calls componentDidMount', () => { |
| 22 | + const spy = spyOn(Component.prototype, 'componentDidMount'); |
| 23 | + const wrapper = mount(<Component id="test" sequence="cgtagtcgatca" />); |
| 24 | + expect(spy).toHaveBeenCalled(); |
| 25 | + }); |
| 26 | + |
| 27 | + it('checking required props', () => { |
| 28 | + const wrapper = mount(<Component id="test" sequence={sequence} />); |
| 29 | + expect(wrapper.props().sequence).toEqual(sequence); |
| 30 | + expect(wrapper.props().id).toEqual("test"); |
| 31 | + }); |
| 32 | + |
| 33 | + /*it('charsPerLine onClick handler fired', () => { |
| 34 | + const spy = createSpy(); |
| 35 | + const wrapper = mount(<Component id="test" sequence={sequence} toolbar={true} handleChange={spy} />); |
| 36 | + console.debug(wrapper.find('.sequenceToolbar')); |
| 37 | + wrapper.find('option[value="100"]').simulate('click'); |
| 38 | + expect(spy).toHaveBeenCalled(); |
| 39 | + });*/ |
| 40 | +}); |
17 | 41 |
|
18 | | - it('displays a welcome message', () => { |
19 | | - render(<Component/>, node, () => { |
20 | | - expect(node.innerHTML).toContain('Welcome to React components') |
21 | | - }) |
22 | | - }) |
23 | | -}) |
|
0 commit comments