Skip to content

Commit

Permalink
Merge pull request #32 from folio-org/react16
Browse files Browse the repository at this point in the history
Upgrade to React 16
  • Loading branch information
doytch committed Feb 7, 2018
2 parents 3d80810 + cfbed2f commit 924ebc9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 15 deletions.
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@
"babel-preset-stage-2": "^6.18.0",
"babel-register": "^6.18.0",
"chai": "^4.0.2",
"enzyme": "^2.6.0",
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1",
"eslint": "^4.7.2",
"eslint-config-stripes": "^0.0.1",
"fetch-mock": "5.11.2",
"jsdom": "^11.0.0",
"jsdom-global": "^3.0.2",
"mocha": "^3.1.2",
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-router": "^4.0.0",
"react-test-renderer": "^15.6.1",
"redux-thunk": "^2.1.0",
"webpack": "^3.6.0"
},
Expand All @@ -42,14 +44,13 @@
"lodash": "^4.17.2",
"prop-types": "^15.5.10",
"query-string": "^5.0.0",
"react": "^15.5.1",
"react-dom": "^15.4.0",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"redux-crud": "^3.0.0",
"uuid": "^3.0.1"
},
"peerDependencies": {
"@folio/stripes-logger": "^0.0.2"
"react": "*",
"react-dom": "*"
}
}
24 changes: 14 additions & 10 deletions test/integration.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import 'jsdom-global/register';
import chai from 'chai';
import { mount, shallow, render } from 'enzyme';
import Enzyme, { mount, shallow, render } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

import React, { Component } from 'react';
import PropTypes from 'prop-types';
Expand All @@ -11,6 +12,9 @@ import fetchMock from 'fetch-mock';

import connect from '../connect';


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

chai.should();

// Provide a redux store and addReducer() function in context
Expand Down Expand Up @@ -166,9 +170,9 @@ describe('connect()', () => {
const inst = mount(<Root store={store} component={Connected}/>);
inst.find(Local).props().resources.localResource.should.equal('hi');
inst.find(Local).props().mutator.localResource.replace({boo:'ya'});
inst.find(Local).props().resources.localResource.boo.should.equal('ya');
inst.find(Local).instance().props.resources.localResource.boo.should.equal('ya');
inst.find(Local).props().mutator.localResource.update({boo:'urns'});
inst.find(Local).props().resources.localResource.boo.should.equal('urns');
inst.find(Local).instance().props.resources.localResource.boo.should.equal('urns');
});

it('should successfully wrap a component with an okapi resource', (done) => {
Expand Down Expand Up @@ -208,8 +212,8 @@ describe('connect()', () => {
fetchMock.lastCall()[1].body.length.should.equal(64);

setTimeout(() => {
inst.find(Remote).props().resources.remoteResource.records[0].someprop.should.equal('someval');
inst.find(Remote).props().resources.remoteResource.successfulMutations[0].record.someprop.should.equal('newer');
inst.find(Remote).instance().props.resources.remoteResource.records[0].someprop.should.equal('someval');
inst.find(Remote).instance().props.resources.remoteResource.successfulMutations[0].record.someprop.should.equal('newer');
fetchMock.restore();
done();
}, 10);
Expand Down Expand Up @@ -237,7 +241,7 @@ describe('connect()', () => {
const inst = mount(<Root store={store} component={Connected}/>);

setTimeout(() => {
inst.find(Paged).props().resources.pagedResource.records.length.should.equal(14);
inst.find(Paged).instance().props.resources.pagedResource.records.length.should.equal(14);
fetchMock.restore();
done();
}, 40);
Expand All @@ -259,8 +263,8 @@ describe('connect()', () => {
inst.find(Functional).props().resources.functionalResource.hasLoaded.should.equal(false);

setTimeout(() => {
inst.find(Functional).props().resources.functionalResource.hasLoaded.should.equal(true);
inst.find(Functional).props().resources.functionalResource.records.length.should.equal(5);
inst.find(Functional).instance().props.resources.functionalResource.hasLoaded.should.equal(true);
inst.find(Functional).instance().props.resources.functionalResource.records.length.should.equal(5);
fetchMock.restore();
done();
}, 10);
Expand All @@ -283,7 +287,7 @@ describe('connect()', () => {
inst.find(ErrorProne).props().mutator.errorProne.POST({id:1, someprop:'new'})
.catch(err => err.text().then(msg => msg.should.equal('You are forbidden because reasons.')));
setTimeout(() => {
const res = inst.find(ErrorProne).props().resources.errorProne;
const res = inst.find(ErrorProne).instance().props.resources.errorProne;
res.isPending.should.equal(false);
res.failed.httpStatus.should.equal(404);
res.failedMutations[0].message.should.equal('You are forbidden because reasons.');
Expand Down Expand Up @@ -318,7 +322,7 @@ describe('connect()', () => {
.catch(err => err.httpStatus.should.equal(403));

setTimeout(() => {
const res = inst.find(Acc).props().resources.accResource;
const res = inst.find(Acc).instance().props.resources.accResource;
res.records[0].someprop.should.equal('someval');
res.records[1].someprop.should.equal('otherval');
inst.find(Acc).props().mutator.accResource.reset();
Expand Down

0 comments on commit 924ebc9

Please sign in to comment.