Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: upgrade enzyme to latest #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"copyfiles": "^1.0.0",
"css-loader": "^0.25.0",
"dotenv": "2.0.0",
"enzyme": "^2.8.2",
"enzyme": "^3.4.1",
"enzyme-adapter-react-15": "^1.0.6",
"eslint": "^3.4.0",
"eslint-loader": "^1.5.0",
"eslint-plugin-compat": "^1.0.2",
Expand Down Expand Up @@ -137,6 +138,7 @@
"<rootDir>/cfg/polyfills.js",
"<rootDir>/cfg/bluebirdPromiseRejection.js"
],
"setupTestFrameworkScriptFile": "<rootDir>src/setupTests.js",
"testPathIgnorePatterns": [
"<rootDir>/(build|docs|node_modules)/",
".test.js"
Expand Down
2 changes: 1 addition & 1 deletion src/components/DropDown.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class DropDown extends React.Component {

handleDropDownChange (e) {
ContainerActions.changeContainer(DATA_TYPE_NAME, this.props.fieldName, {value: e.target.value});
setTimeout(() => this.props.onDropDownFocus(this.props.fieldName), 100); // TODO: fix this hack
//setTimeout(() => this.props.onDropDownFocus(this.props.fieldName), 100); // TODO: fix this hack
}

render () {
Expand Down
19 changes: 9 additions & 10 deletions src/components/DropDown.spec.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
import React from 'react';
import { mount, render, shallow } from 'enzyme';
import {shallow } from 'enzyme';
import DropDown from './DropDown';

jest.mock('../actions/ContainerActions');
const FakeContainerActions = require('../actions/ContainerActions');

describe('DropDown', () => {
it('renders without crashing', () => {
expect(() => mount(
<DropDown />
)).not.toThrow();
const component = shallow(<DropDown/>)
expect(component.exists()).toBe(true)
});

it('displays its name in the label', () => {
const component = render(<DropDown fieldName='mario'/>)
const component = shallow(<DropDown fieldName='mario'/>)

expect(component.find('label').text()).toEqual('mario');
});
Expand All @@ -23,16 +22,16 @@ describe('DropDown', () => {
{name: 'Mario', value: 'mario'},
{name: 'Luigi', value: 'luigi'}
];
const component = mount(<DropDown fieldName='mario' options={ options }/>)

const component = shallow(<DropDown fieldName='mario' options={ options }/>)
expect(component.find('option').length).toEqual(2);
expect(component.find('option').get(0).value).toEqual('mario');
expect(component.find('option').get(1).value).toEqual('luigi');
});
expect(component.find('option').first().props().value).toEqual('mario');
expect(component.find('option').get(1).props.value).toEqual('luigi');
});

it('calls the onDropDownChange function when a change is made', () => {
const fakeChange = {target: {value: 'stuff'}};
const component = mount(<DropDown fieldName='myName' />)
const component = shallow(<DropDown fieldName='myName' />)

component.find('select').simulate('change', fakeChange);

Expand Down
14 changes: 7 additions & 7 deletions src/components/ImageContainer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,9 +242,9 @@ describe('ImageContainer', () => {
let settings = capSettings();
const component = mount(<ImageContainer {...getProps(settings)}/>);

expect(component.find('input').get(0).placeholder).toEqual('one');
expect(component.find('input').get(1).placeholder).toEqual('two');
expect(component.find('input').get(2).placeholder).toEqual('three');
expect(component.find('input').get(0).props.placeholder).toEqual('one');
expect(component.find('input').get(1).props.placeholder).toEqual('two');
expect(component.find('input').get(2).props.placeholder).toEqual('three');
});

describe('filter options', () => {
Expand Down Expand Up @@ -311,10 +311,10 @@ describe('ImageContainer', () => {

const component = mount(<ImageContainer {...getProps({images})}/>);

expect(component.find('select').get(0).value).toEqual('1');
expect(component.find('select').get(1).value).toEqual('1');
expect(component.find('select').get(2).value).toEqual('2');
expect(component.find('select').get(3).value).toEqual('4');
expect(component.find('select').get(0).props.value).toEqual('1');
expect(component.find('select').get(1).props.value).toEqual('1');
expect(component.find('select').get(2).props.value).toEqual('2');
expect(component.find('select').get(3).props.value).toEqual('4');
});

it('will send option changes up the stack', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ImageDropDown.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ describe('ImageDropDown', () => {
const component = mount(<ImageDropDown {...props}/>)

expect(component.find('option').length).toEqual(2);
expect(component.find('option').get(0).value).toEqual('mario');
expect(component.find('option').get(1).value).toEqual('luigi');
expect(component.find('option').get(0).props.value).toEqual('mario');
expect(component.find('option').get(1).props.value).toEqual('luigi');
});

it('calls the onDropDownFocus function when the input field is focused', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/setupTests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import Enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-15';

Enzyme.configure({ adapter: new Adapter() });
Loading