Skip to content

Commit

Permalink
chore(package): update enzyme to version 3.5.0 (#469)
Browse files Browse the repository at this point in the history
* chore(package): update enzyme to version 3.5.0

Closes #448

* chore(package): update enzyme-adapter-react-16 to version 1.3.0

Closes #448

* chore(tests): make container queries more resilient

* chore(label): make htmlFor an implicit prop

* chore(package): update lockfile
  • Loading branch information
mhuggins authored Aug 25, 2018
1 parent 1eeea04 commit 3a33779
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ import { mount } from 'enzyme';
import { provideStore, createStore, spunkyKey, mockSpunkyLoaded } from 'testHelpers';

import TransactionsPanel from 'account/components/TransactionsPanel';
import Send from 'account/components/TransactionsPanel/Send';
import Receive from 'account/components/TransactionsPanel/Receive';
import IconTab from 'account/components/TransactionsPanel/IconTab';
import { NEO } from 'shared/values/assets';

const initialState = {
Expand Down Expand Up @@ -38,14 +41,14 @@ const mountContainer = (props = {}) => {
describe('<TransactionsPanel />', () => {
it('renders the Send tab contents', () => {
const wrapper = mountContainer();
expect(wrapper.find('Send').exists()).toBe(true);
expect(wrapper.find('Receive').exists()).toBe(false);
expect(wrapper.find(Send).exists()).toBe(true);
expect(wrapper.find(Receive).exists()).toBe(false);
});

it('switches to the Receive tab', () => {
const wrapper = mountContainer();
wrapper.find('IconTab').filterWhere((el) => el.text() === 'Receive').simulate('click');
expect(wrapper.find('Send').exists()).toBe(false);
expect(wrapper.find('Receive').exists()).toBe(true);
wrapper.find(IconTab).filterWhere((el) => el.text() === 'Receive').simulate('click');
expect(wrapper.find(Send).exists()).toBe(false);
expect(wrapper.find(Receive).exists()).toBe(true);
});
});
12 changes: 7 additions & 5 deletions __tests__/renderer/account/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { mount } from 'enzyme';
import { provideStore, createStore, spunkyKey, mockSpunkyLoaded } from 'testHelpers';

import { Account } from 'account';
import AccountPanel from 'account/components/AccountPanel';
import TransactionsPanel from 'account/components/TransactionsPanel';
import { NEO, GAS } from 'shared/values/assets';
import { DEFAULT_CURRENCY } from 'shared/values/currencies';

Expand Down Expand Up @@ -38,19 +40,19 @@ const initialState = {
}
};

const mountAccount = (state = initialState) => {
const mountContainer = (state = initialState) => {
const store = createStore(state);
return mount(provideStore(<Account />, store));
};

describe('<Account />', () => {
it('renders the account panel', () => {
const wrapper = mountAccount();
expect(wrapper.find('AccountPanel').exists()).toBe(true);
const wrapper = mountContainer();
expect(wrapper.find(AccountPanel).exists()).toBe(true);
});

it('renders the transactions panel', () => {
const wrapper = mountAccount();
expect(wrapper.find('TransactionsPanel').exists()).toBe(true);
const wrapper = mountContainer();
expect(wrapper.find(TransactionsPanel).exists()).toBe(true);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { mount } from 'enzyme';

import AccountDatum from 'register/components/AccountDetails/AccountDatum/AccountDatum';
import Icon from 'shared/components/Icon';

describe('<AccountDatum />', () => {
const mountContainer = (props = {}) => {
Expand All @@ -21,7 +22,7 @@ describe('<AccountDatum />', () => {
it('calls showInfoToast prop when copy icon is clicked', () => {
const showToastSpy = jest.fn();
const wrapper = mountContainer({ showInfoToast: showToastSpy });
wrapper.find('Icon').simulate('click');
wrapper.find(Icon).simulate('click');
expect(showToastSpy).toHaveBeenCalledWith('Address copied to clipboard.');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { shallow } from 'enzyme';

import AccountDetails from 'register/components/AccountDetails/AccountDetails';
import AccountDatum from 'register/components/AccountDetails/AccountDatum';

describe('<AccountDetails />', () => {
const account = {
Expand All @@ -13,7 +14,7 @@ describe('<AccountDetails />', () => {
let wrapper;

const findDatum = (label) => {
return wrapper.find('Connect(AccountDatum)').findWhere((node) => node.prop('label') === label);
return wrapper.find(AccountDatum).findWhere((node) => node.prop('label') === label);
};

beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import { mount } from 'enzyme';

import LabeledInput from 'shared/components/Forms/LabeledInput';
import Label from 'shared/components/Forms/Label';
import Input from 'shared/components/Forms/Input';

const mountContainer = (props = {}) => {
return mount(<LabeledInput {...props} />);
Expand All @@ -10,15 +12,15 @@ const mountContainer = (props = {}) => {
describe('<LabeledInput />', () => {
it('renders a label', () => {
const wrapper = mountContainer({ id: 'name', label: 'Name' });
const label = wrapper.find('Label');
const label = wrapper.find(Label);
expect(label.exists()).toBe(true);
expect(label.props()).toEqual(expect.objectContaining({ label: 'Name', htmlFor: 'name' }));
});

it('renders an input', () => {
const inputProps = { id: 'pw', type: 'password', defaultValue: 'foo' };
const wrapper = mountContainer({ label: 'Password', ...inputProps });
const input = wrapper.find('Input');
const input = wrapper.find(Input);
expect(input.exists()).toBe(true);
expect(input.props()).toEqual(expect.objectContaining(inputProps));
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import React from 'react';
import { mount } from 'enzyme';

import LabeledSelect from 'shared/components/Forms/LabeledSelect';
import Label from 'shared/components/Forms/Label';
import Select from 'shared/components/Forms/Select';

const mountContainer = (props = {}) => {
return mount(<LabeledSelect {...props} />);
Expand All @@ -10,7 +12,7 @@ const mountContainer = (props = {}) => {
describe('<LabeledSelect />', () => {
it('renders a label', () => {
const wrapper = mountContainer({ id: 'currency', label: 'Currency' });
const label = wrapper.find('Label');
const label = wrapper.find(Label);
expect(label.exists()).toBe(true);
expect(label.props()).toEqual(expect.objectContaining({ label: 'Currency', htmlFor: 'currency' }));
});
Expand All @@ -23,7 +25,7 @@ describe('<LabeledSelect />', () => {
</React.Fragment>
);
const wrapper = mountContainer({ id: 'currency', label: 'Currency', children });
const select = wrapper.find('Select');
const select = wrapper.find(Select);
expect(select.exists()).toBe(true);
expect(select.props()).toEqual(expect.objectContaining({ id: 'currency', children }));
});
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
"electron-devtools-installer": "2.2.4",
"electron-rebuild": "1.8.2",
"electron-webpack": "1.13.0",
"enzyme": "3.3.0",
"enzyme-adapter-react-16": "1.2.0",
"enzyme": "3.5.0",
"enzyme-adapter-react-16": "1.3.0",
"eslint": "5.3.0",
"eslint-config-airbnb": "17.1.0",
"eslint-import-resolver-babel-module": "4.0.0",
Expand Down
5 changes: 2 additions & 3 deletions src/renderer/shared/components/Forms/Label/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default class Label extends React.PureComponent {
static propTypes = {
className: string,
label: node.isRequired,
htmlFor: string.isRequired,
children: node
};

Expand All @@ -20,10 +19,10 @@ export default class Label extends React.PureComponent {
};

render() {
const { className, label, children, htmlFor, ...passDownProps } = this.props;
const { className, label, children, ...passDownProps } = this.props;

return (
<label {...passDownProps} htmlFor={htmlFor} className={classNames(styles.wrapper, className)}>
<label {...passDownProps} className={classNames(styles.wrapper, className)}>
<span className={styles.label}>
{label}
</span>
Expand Down
68 changes: 40 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,14 @@ array-unique@^0.3.2:
version "0.3.2"
resolved "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428"

array.prototype.flat@^1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.1.tgz#812db8f02cad24d3fab65dd67eabe3b8903494a4"
dependencies:
define-properties "^1.1.2"
es-abstract "^1.10.0"
function-bind "^1.1.1"

arrify@^1.0.0, arrify@^1.0.1:
version "1.0.1"
resolved "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
Expand Down Expand Up @@ -3235,41 +3243,42 @@ entities@^1.1.1, entities@~1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/entities/-/entities-1.1.1.tgz#6e5c2d0a5621b5dadaecef80b90edfb5cd7772f0"

enzyme-adapter-react-16@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.2.0.tgz#c6e80f334e0a817873262d7d01ee9e4747e3c97e"
enzyme-adapter-react-16@1.3.0:
version "1.3.0"
resolved "https://registry.npmjs.org/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.3.0.tgz#4cfba44f8c27256d28e171bdf7a5b5aebce6041b"
dependencies:
enzyme-adapter-utils "^1.5.0"
enzyme-adapter-utils "^1.6.0"
function.prototype.name "^1.1.0"
object.assign "^4.1.0"
object.values "^1.0.4"
prop-types "^15.6.2"
react-is "^16.4.2"
react-reconciler "^0.7.0"
react-test-renderer "^16.0.0-0"

enzyme-adapter-utils@^1.5.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/enzyme-adapter-utils/-/enzyme-adapter-utils-1.5.0.tgz#a020ab3ae79bb1c85e1d51f48f35e995e0eed810"
enzyme-adapter-utils@^1.6.0:
version "1.6.0"
resolved "https://registry.npmjs.org/enzyme-adapter-utils/-/enzyme-adapter-utils-1.6.0.tgz#c59a3f311769fc4087489bff3ee98d8397682c75"
dependencies:
function.prototype.name "^1.1.0"
object.assign "^4.1.0"
prop-types "^15.6.2"

enzyme@3.3.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/enzyme/-/enzyme-3.3.0.tgz#0971abd167f2d4bf3f5bd508229e1c4b6dc50479"
enzyme@3.5.0:
version "3.5.0"
resolved "https://registry.npmjs.org/enzyme/-/enzyme-3.5.0.tgz#fd452a698fd1352c737b641dd3a64e079f42d9d5"
dependencies:
array.prototype.flat "^1.2.1"
cheerio "^1.0.0-rc.2"
function.prototype.name "^1.0.3"
has "^1.0.1"
function.prototype.name "^1.1.0"
has "^1.0.3"
is-boolean-object "^1.0.0"
is-callable "^1.1.3"
is-callable "^1.1.4"
is-number-object "^1.0.3"
is-string "^1.0.4"
is-subset "^0.1.1"
lodash "^4.17.4"
object-inspect "^1.5.0"
lodash.escape "^4.0.1"
lodash.isequal "^4.5.0"
object-inspect "^1.6.0"
object-is "^1.0.1"
object.assign "^4.1.0"
object.entries "^1.0.4"
Expand Down Expand Up @@ -4182,7 +4191,7 @@ function-bind@^1.0.2, function-bind@^1.1.0, function-bind@^1.1.1:
version "1.1.1"
resolved "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"

function.prototype.name@^1.0.3, function.prototype.name@^1.1.0:
function.prototype.name@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/function.prototype.name/-/function.prototype.name-1.1.0.tgz#8bd763cc0af860a859cc5d49384d74b932cd2327"
dependencies:
Expand Down Expand Up @@ -4953,6 +4962,10 @@ is-callable@^1.1.1, is-callable@^1.1.3:
version "1.1.3"
resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.1.3.tgz#86eb75392805ddc33af71c92a0eedf74ee7604b2"

is-callable@^1.1.4:
version "1.1.4"
resolved "https://registry.npmjs.org/is-callable/-/is-callable-1.1.4.tgz#1e1adf219e1eeb684d691f9d6a05ff0d30a24d75"

is-ci@^1.0.10, is-ci@^1.1.0:
version "1.1.0"
resolved "https://registry.npmjs.org/is-ci/-/is-ci-1.1.0.tgz#247e4162e7860cebbdaf30b774d6b0ac7dcfe7a5"
Expand Down Expand Up @@ -5967,6 +5980,10 @@ lodash.clonedeep@^4.3.2:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"

lodash.escape@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/lodash.escape/-/lodash.escape-4.0.1.tgz#c9044690c21e04294beaa517712fded1fa88de98"

lodash.flattendeep@^4.4.0:
version "4.4.0"
resolved "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"
Expand All @@ -5979,6 +5996,10 @@ lodash.isarray@^3.0.0:
version "3.0.4"
resolved "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55"

lodash.isequal@^4.5.0:
version "4.5.0"
resolved "https://registry.npmjs.org/lodash.isequal/-/lodash.isequal-4.5.0.tgz#415c4478f2bcc30120c22ce10ed3226f7d3e18e0"

lodash.isplainobject@^4.0.6:
version "4.0.6"
resolved "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz#7c526a52d89b45c45cc690b88163be0497f550cb"
Expand Down Expand Up @@ -6780,9 +6801,9 @@ object-copy@^0.1.0:
define-property "^0.2.5"
kind-of "^3.0.3"

object-inspect@^1.5.0:
object-inspect@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.6.0.tgz#c70b6cbf72f274aab4c34c0c82f5167bf82cf15b"
resolved "https://registry.npmjs.org/object-inspect/-/object-inspect-1.6.0.tgz#c70b6cbf72f274aab4c34c0c82f5167bf82cf15b"

object-is@^1.0.1:
version "1.0.1"
Expand Down Expand Up @@ -7980,15 +8001,6 @@ react-lifecycles-compat@^3.0.2, react-lifecycles-compat@^3.0.4:
version "3.0.4"
resolved "https://registry.npmjs.org/react-lifecycles-compat/-/react-lifecycles-compat-3.0.4.tgz#4f1a273afdfc8f3488a8c516bfda78f872352362"

react-reconciler@^0.7.0:
version "0.7.0"
resolved "https://registry.npmjs.org/react-reconciler/-/react-reconciler-0.7.0.tgz#9614894103e5f138deeeb5eabaf3ee80eb1d026d"
dependencies:
fbjs "^0.8.16"
loose-envify "^1.1.0"
object-assign "^4.1.1"
prop-types "^15.6.0"

[email protected], react-redux@^5.0.6:
version "5.0.7"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.7.tgz#0dc1076d9afb4670f993ffaef44b8f8c1155a4c8"
Expand Down

0 comments on commit 3a33779

Please sign in to comment.