Skip to content
This repository was archived by the owner on Mar 17, 2021. It is now read-only.

Commit 63bf086

Browse files
authored
Merge pull request #249 from Adam13531/master
Upgrade to React 16
2 parents 6c2fb96 + 61296fc commit 63bf086

8 files changed

+31
-17
lines changed

package.json

+7-5
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@
4343
"babel-preset-stage-2": "6.18.0",
4444
"chai": "3.5.0",
4545
"codecov": "1.0.1",
46-
"enzyme": "2.6.0",
46+
"enzyme": "3.3.0",
47+
"enzyme-adapter-react-16": "1.1.1",
4748
"eslint": "3.12.2",
4849
"eslint-config-airbnb": "13.0.0",
4950
"eslint-plugin-import": "2.2.0",
@@ -55,16 +56,17 @@
5556
"mocha": "3.2.0",
5657
"npm-run-all": "3.1.2",
5758
"nyc": "^10.0.0",
58-
"react": "15.4.1",
59+
"prop-types": "^15.5.8",
60+
"react": "16.2.0",
5961
"react-addons-test-utils": "15.4.1",
60-
"react-dom": "15.4.1",
62+
"react-dom": "16.2.0",
6163
"sinon": "1.17.6",
6264
"webpack": "1.14.0",
6365
"webpack-dev-server": "1.16.2"
6466
},
6567
"peerDependencies": {
66-
"react": "^0.14.7 || ^15.0.1",
67-
"react-dom": "^0.14.7 || ^15.0.1"
68+
"react": "^0.14.7 || ^15.0.1 || ^16.0",
69+
"react-dom": "^0.14.7 || ^15.0.1 || ^16.0"
6870
},
6971
"dependencies": {
7072
"tween-functions": "^1.2.0"

src/anchor-element.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* Provides the anchor-panel which can be linked to by `anchor`-augmented componented
33
*/
4-
import React, { PropTypes as PT, Component } from 'react';
4+
import React, { Component } from 'react';
5+
import { PropTypes as PT } from 'prop-types';
56
import scroller from './scroller';
67
import CtxTypes from './ctx-types';
78
import { filterUndefined } from './utils';

src/anchor.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* Exports a helper function which wraps clickable elements, hijacking onClick and passing it to the scroller
33
*/
4-
import React, { PropTypes as PT } from 'react';
4+
import React from 'react';
5+
import { PropTypes as PT } from 'prop-types';
56
import ReactDOM from 'react-dom';
67
import scroller from './scroller';
78
import ScrollSpy from './scroll-spy';

src/ctx-types.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* Proptypes used for the context
33
*/
4-
import { PropTypes as PT } from 'react';
4+
import { PropTypes as PT } from 'prop-types';
55

66
export const contextTypes = {
77
offset: PT.number,

src/scroll-panel.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
/**
22
* A component to use when you want scrolling other places than the global document
33
*/
4-
import React, { PropTypes as PT } from 'react';
4+
import React from 'react';
5+
import { PropTypes as PT } from 'prop-types';
56
import CtxTypes from './ctx-types';
67
import ScrollSpy from './scroll-spy';
78
import { omit } from './utils';

test/anchor-element-test.js

+7-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
import React from 'react';
44
import { expect } from 'chai';
55
import { spy } from 'sinon';
6-
import { mount } from 'enzyme';
6+
import Adapter from 'enzyme-adapter-react-16';
7+
import Enzyme, { mount } from 'enzyme';
78
import AnchorElement from './../src/anchor-element';
89
import { defaultConfig } from './../src/ctx-types';
910
import { omit } from './test-utils';
1011

12+
Enzyme.configure({ adapter: new Adapter() });
13+
1114
describe('AnchorElement', () => {
1215
it('should register with scroller on mount', () => {
1316
const registerElementPanel = spy();
@@ -37,15 +40,15 @@ describe('AnchorElement', () => {
3740
describe('getConfig', () => {
3841
it('should return defaults if no props are provided', () => {
3942
const wrapper = mount(<AnchorElement id="test"><h1>Test</h1></AnchorElement>);
40-
const config = wrapper.node.getConfig();
43+
const config = wrapper.instance().getConfig();
4144

4245
expect(omit(config, ['children', 'isInside', 'id'])).to.deep.equal(defaultConfig);
4346
});
4447

4548
it('should inherit from context', () => {
4649
const ctx = { offset: 10, events: { test: 0 }, animate: false, container: {} };
4750
const wrapper = mount(<AnchorElement id="test"><h1>Test</h1></AnchorElement>, { context: ctx });
48-
const config = wrapper.node.getConfig();
51+
const config = wrapper.instance().getConfig();
4952

5053
expect(omit(config, ['children', 'isInside', 'id'])).to.not.deep.equal(defaultConfig);
5154
expect(omit(config, ['children', 'isInside', 'id'])).to.deep.equal(ctx);
@@ -59,7 +62,7 @@ describe('AnchorElement', () => {
5962
{ context: ctx }
6063
);
6164

62-
const config = wrapper.node.getConfig();
65+
const config = wrapper.instance().getConfig();
6366

6467
expect(omit(config, ['children', 'isInside', 'id'])).to.not.deep.equal(defaultConfig);
6568
expect(omit(config, ['children', 'isInside', 'id'])).to.not.deep.equal(ctx);

test/anchor-test.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
import React from 'react';
44
import { expect } from 'chai';
55
import { spy } from 'sinon';
6-
import { mount } from 'enzyme';
6+
import Adapter from 'enzyme-adapter-react-16';
7+
import Enzyme, { mount } from 'enzyme';
78
import anchor from './../src/anchor';
89
import { AnchorButton } from './../src/index';
910

11+
Enzyme.configure({ adapter: new Adapter() });
12+
1013
describe('Anchor', () => {
1114
it('should call prepareToScroll onClick', () => {
1215
const prepareToScroll = spy();

test/scroller-test.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,22 @@
22
/* eslint-disable newline-per-chained-call */
33
import React from 'react';
44
import ReactDOM from 'react-dom';
5-
import { mount } from 'enzyme';
5+
import Adapter from 'enzyme-adapter-react-16';
6+
import Enzyme, { mount } from 'enzyme';
67
import { spy } from 'sinon';
78
import { expect } from 'chai';
89
import AnchorElement from './../src/anchor-element';
910
import { Scroller } from './../src/scroller';
1011

12+
Enzyme.configure({ adapter: new Adapter() });
13+
1114
// Utils
1215
const size = (instance) => Object.keys(instance._elementPanelRegister).length;
1316
const createAnchorElement = () => {
1417
const wrapper = mount(<AnchorElement id="test"><h1>Test</h1></AnchorElement>);
15-
spy(wrapper.node, 'getConfig');
18+
spy(wrapper.instance(), 'getConfig');
1619

17-
return wrapper.node;
20+
return wrapper.instance();
1821
};
1922

2023
// So we can work on a clean instance for each test

0 commit comments

Comments
 (0)