diff --git a/package.json b/package.json index ada4ad6..17809f1 100644 --- a/package.json +++ b/package.json @@ -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" }, @@ -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": "*" } } diff --git a/test/integration.js b/test/integration.js index 269ec99..f98bd9f 100644 --- a/test/integration.js +++ b/test/integration.js @@ -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'; @@ -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 @@ -166,9 +170,9 @@ describe('connect()', () => { const inst = mount(); 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) => { @@ -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); @@ -237,7 +241,7 @@ describe('connect()', () => { const inst = mount(); 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); @@ -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); @@ -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.'); @@ -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();