Skip to content

Commit

Permalink
migrated enzyme to use adapter for react 16
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdugne committed Nov 15, 2017
1 parent 5c1cd1e commit f35ce74
Show file tree
Hide file tree
Showing 30 changed files with 123 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Checkbox from '..';

configure({adapter: new Adapter()});

test('should call the onChange function and toggle the value on change', t => {
t.plan(5);
const expectedOnChangeValues = [false, true];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import replace from 'lodash/fp/replace';
import Clue from '..';
import style from '../style.css'; // eslint-disable-line css-modules/no-unused-class
import defaultFixture from './fixtures/default';

configure({adapter: new Adapter()});

test('should See the clue', t => {
const context = {
skin: {},
Expand Down
5 changes: 4 additions & 1 deletion packages/@coorpacademy-components/src/atom/cta/test/hover.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Cta from '..';
import ctaFixture from './fixtures/primary';

configure({adapter: new Adapter()});

const context = {
skin: {
common: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import ImageUpload from '..';
import desktopFixture from './fixtures/desktop';

configure({adapter: new Adapter()});

test('should set state to dragging when user starts dragging', t => {
const wrapper = shallow(<ImageUpload {...desktopFixture.props} />);
const instance = wrapper.instance();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import InputCheckbox from '..';
import defaultFixture from './fixtures/default';

configure({adapter: new Adapter()});

test('should call the onChange function with the checked value of the target', t => {
t.plan(2);
const expectedOnChangeValues = [false, true];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import 'jsdom-global/register';
import test from 'ava';
import {replace} from 'lodash/fp';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import InputDoublestep from '..';
import style from '../style.css'; // eslint-disable-line css-modules/no-unused-class
import inputConfirmFixture from './fixtures/input-confirm';

configure({adapter: new Adapter()});

test('should call the onChange function on change with inputConfirm fixture', t => {
const deleteStyle = `.${replace(' ', '.', style.delete)}`;
const inputStyle = `.${replace(' ', '.', style.input)}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow, mount} from 'enzyme';
import {shallow, mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import omit from 'lodash/fp/omit';
import replace from 'lodash/fp/replace';
import InputHtml from '..';
import style from '../style.css'; // eslint-disable-line css-modules/no-unused-class
import defaultFixture from './fixtures/default';

configure({adapter: new Adapter()});

test('should call the onChange function with the value of the target', t => {
t.plan(15);
const inputStyle = `.${replace(' ', '.', style.input)}`;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import InputSwitch from '..';
import defaultFixture from './fixtures/checked';

configure({adapter: new Adapter()});

test('should call the onChange function with the checked value of the target', t => {
t.plan(2);
const expectedOnChangeValues = [false, true];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import InputTextarea from '..';
import omit from 'lodash/fp/omit';
import defaultFixture from './fixtures/default';

configure({adapter: new Adapter()});

test('should call the onChange function with the value of the target', t => {
t.plan(1);
const onChange = value => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import once from 'lodash/fp/once';
import Link from '..';

configure({adapter: new Adapter()});

test('should call listeners within props', t => {
t.plan(3);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Provider from '..';
import noop from 'lodash/fp/noop';
import defaultFixture from './fixtures/default';

configure({adapter: new Adapter()});

test('should re-render element when updating props', t => {
const history = {
createHref: noop,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Handle from '../handle';

configure({adapter: new Adapter()});

test('should instanciate Handle', t => {
const handler = mount(<Handle />);
handler.unmount();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import noop from 'lodash/fp/noop';
import Range from '..'; // eslint-disable-line no-shadow
import style from '../style.css'; // eslint-disable-line css-modules/no-unused-class

configure({adapter: new Adapter()});

const defaultEvent = {
stopPropagation: noop,
preventDefault: noop
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Select from '..';
import defaultFixture from './fixtures/default';

configure({adapter: new Adapter()});

test('should call onChange with the target value if multiple=false', t => {
t.plan(1);
const onChange = value => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Tab from '..';
import style from '../style.css'; // eslint-disable-line css-modules/no-unused-class
import defaultFixture from './fixtures/default';

configure({adapter: new Adapter()});

test('should call onClick with the targetContent value', t => {
t.plan(1);
const onClick = value => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import once from 'lodash/fp/once';
import BrandCreateForm from '..';

configure({adapter: new Adapter()});

test('should submit form', t => {
t.plan(2);
const props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import CardsList from '..';
import Card from '../../../card/test/fixtures/default';

configure({adapter: new Adapter()});

const mountCardsList = props => {
const component = <CardsList {...props} />;
const cards = mount(component);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Filters from '..';

configure({adapter: new Adapter()});

test('mount Filters with enzyme', t => {
t.plan(9);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import VideoIframe from '..';

configure({adapter: new Adapter()});

test('should render properly a kontiki iframe', t => {
const props = {
type: 'kontiki',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {shallow} from 'enzyme';
import {shallow, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Player from '..';

configure({adapter: new Adapter()});

test('should emit play only one', t => {
const events = ['Play', 'Resume', 'Play', 'Resume', 'Resume'];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import JWPlayer from '../jwplayer';

configure({adapter: new Adapter()});

test('should call listeners within props, then remove them on willComponentUnmount', t => {
t.plan(4);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import 'jsdom-global/register';
import EventEmitter from 'events'; // eslint-disable-line fp/no-events
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import Vimeo from '../vimeo';

configure({adapter: new Adapter()});

class Player extends EventEmitter {
constructor() {
super();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import once from 'lodash/fp/once';
import BrandForm from '..';

configure({adapter: new Adapter()});

test('should submit form', t => {
t.plan(2);
const props = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import replace from 'lodash/fp/replace';
import {InputTextItem} from '..';
import style from '../style.css'; // eslint-disable-line css-modules/no-unused-class

configure({adapter: new Adapter()});

const defaultFixture = {
title: 'Bar',
value: 'Foo'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import correctClosed from './fixtures/correct-closed';
import PopinCorrection from '..';

configure({adapter: new Adapter()});

test.cb('should open with transition', t => {
const props = {onOpen: t.end, ...correctClosed.props};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import 'jsdom-global/register';
import test from 'ava';
import React from 'react';
import PropTypes from 'prop-types';
import {mount} from 'enzyme';
import {mount, configure} from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
import DashboardPreview from '..';

import defaultFixture from './fixtures/selected';

configure({adapter: new Adapter()});

test('should call the onSelectDashboard function with the value of the target', t => {
t.plan(2);

Expand Down
Loading

0 comments on commit f35ce74

Please sign in to comment.