From 16df641e6ebd7709f91a2a4bc641cd9bf98266f7 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 11:50:05 -0800 Subject: [PATCH 01/20] Update to RN 0.49 - update enzyme and use enzyme's react 16 adapter - add RN and react devDeps for now (reflects the peerDeps) - Add newly required `reactNativeVersion` and `DeviceInfo` properties to the `NativeModules` - `reactNativeVersion` reads from the RN source - `DeviceInfo` is set to iPhone 6 --- package.json | 11 ++++++++--- scripts/test-helper.js | 3 +++ src/NativeModules.js | 14 +++++++++++++- tests/integration/components.test.js | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index dbab5ac..7779514 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ }, "homepage": "https://github.com/RealOrangeOne/react-native-mock#readme", "dependencies": { + "enzyme-adapter-react-16": "1.0.2", "glob": "7.1.1", "mockery": "2.0.0", "perfy": "1.1.2", @@ -45,7 +46,7 @@ "babel-cli": "6.9.0", "chai": "3.5.0", "chai-as-promised": "6.0.0", - "enzyme": "2.8.0", + "enzyme": "3.1.0", "eslint": "2.10.2", "eslint-config-airbnb": "9.0.1", "eslint-plugin-import": "1.8.0", @@ -56,13 +57,17 @@ "mocha": "3.2.0", "mocha-assume": "1.0.0", "nyc": "10.0.0", + "react": "16.0.0-beta.5", + "react-dom": "16.0.0-beta.5", + "react-native": "0.49", "semver": "5.3.0", "sinon-chai": "2.8.0" }, "peerDependencies": { "babel-core": "*", "babel-preset-react-native": "*", - "react": ">=15.4.0", - "react-native": ">=0.38.0" + "react": ">=16.0.0-beta.5", + "react-dom": ">=16.0.0-beta.5", + "react-native": ">=0.49.0" } } diff --git a/scripts/test-helper.js b/scripts/test-helper.js index 478ee06..ede8982 100644 --- a/scripts/test-helper.js +++ b/scripts/test-helper.js @@ -2,6 +2,9 @@ const chai = require('chai'); const sinonChai = require('sinon-chai'); const chaiAsPromised = require('chai-as-promised'); const jsdom = require('jsdom'); +const Enzyme = require('enzyme'); +const React16Adapter = require('enzyme-adapter-react-16'); +Enzyme.configure({ adapter: new React16Adapter() }); chai.expect(); chai.use(sinonChai); diff --git a/src/NativeModules.js b/src/NativeModules.js index 1e9e436..370e1e6 100644 --- a/src/NativeModules.js +++ b/src/NativeModules.js @@ -1,4 +1,5 @@ import sinon from 'sinon'; +const ReactNativeVersion = require('react-native/Libraries/Core/ReactNativeVersion'); module.exports = { AlertManager: { @@ -145,7 +146,8 @@ module.exports = { osVersion: '10', interfaceIdiom: 'pad', isTesting: true, - version: '7' + version: '7', + reactNativeVersion: ReactNativeVersion.version }, AndroidConstants: { Version: '7', @@ -155,5 +157,15 @@ module.exports = { osVersion: '10', interfaceIdiom: 'pad', isTesting: true + }, + DeviceInfo: { + Dimensions: { + windowPhysicalPixels: { // iPhone 6 + fontScale: 2, + height: 1334, + scale: 2, + width: 750 + } + } } }; diff --git a/tests/integration/components.test.js b/tests/integration/components.test.js index c90e0e3..1b2e04e 100644 --- a/tests/integration/components.test.js +++ b/tests/integration/components.test.js @@ -113,7 +113,7 @@ describe('Components', function () { it('should render ProgressBarAndroid', function () { const { ProgressBarAndroid } = ReactNative; const instance = shallow(); - expect(instance.html()).to.include(' Date: Sun, 5 Nov 2017 11:57:02 -0800 Subject: [PATCH 02/20] Fix BackAndroid and add BackHandler - BackAndroid is deprecated by BackHandler - added test for BackHandler - Remove obsolete test of `addEventListener().remove()` --- tests/integration/apis/BackAndroid.test.js | 9 --------- tests/integration/apis/BackHandler.test.js | 11 +++++++++++ 2 files changed, 11 insertions(+), 9 deletions(-) create mode 100644 tests/integration/apis/BackHandler.test.js diff --git a/tests/integration/apis/BackAndroid.test.js b/tests/integration/apis/BackAndroid.test.js index 7a9645c..ee5b048 100644 --- a/tests/integration/apis/BackAndroid.test.js +++ b/tests/integration/apis/BackAndroid.test.js @@ -1,20 +1,11 @@ import { expect } from 'chai'; -import sinon from 'sinon'; describe('BackAndroid', () => { const { BackAndroid } = require('react-native'); it('should bind events', function () { expect(BackAndroid.addEventListener).to.be.a('function'); - expect(BackAndroid.addEventListener().remove).to.be.a('function'); expect(BackAndroid.removeEventListener).to.be.a('function'); expect(BackAndroid.exitApp).to.be.a('function'); }); - - it('should remove', function () { - sinon.stub(BackAndroid, 'removeEventListener'); - BackAndroid.addEventListener().remove(); - expect(BackAndroid.removeEventListener).to.have.been.calledOnce; - BackAndroid.removeEventListener.restore(); - }); }); diff --git a/tests/integration/apis/BackHandler.test.js b/tests/integration/apis/BackHandler.test.js new file mode 100644 index 0000000..a201bd6 --- /dev/null +++ b/tests/integration/apis/BackHandler.test.js @@ -0,0 +1,11 @@ +import { expect } from 'chai'; + +describe('BackHandler', () => { + const { BackHandler } = require('react-native'); + + it('should bind events', function () { + expect(BackHandler.addEventListener).to.be.a('function'); + expect(BackHandler.removeEventListener).to.be.a('function'); + expect(BackHandler.exitApp).to.be.a('function'); + }); +}); From 84cb37babbd0e2fbb2e501366cba0e39f6be5d70 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 11:57:53 -0800 Subject: [PATCH 03/20] Remove `Navigator` test as it was removed from RN --- tests/integration/components.test.js | 9 --------- 1 file changed, 9 deletions(-) diff --git a/tests/integration/components.test.js b/tests/integration/components.test.js index 1b2e04e..c916779 100644 --- a/tests/integration/components.test.js +++ b/tests/integration/components.test.js @@ -78,15 +78,6 @@ describe('Components', function () { expect(instance.html()).to.equal(buildComponentHTML('View')); }); - it('should render Navigator', function () { - const { Navigator, Text } = ReactNative; - const renderScene = sinon.spy((route, navigator) => Hello!); - const instance = shallow(); - expect(instance.html()).to.include('View'); - expect(instance.html()).to.include('Hello!'); - expect(renderScene).to.have.been.called; - }); - it('should render NavigatorIOS', function () { const { NavigatorIOS, Text } = ReactNative; const initialRoute = { From d8e686990f59cfbd6c8f7f3ecc12719947f14c83 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 12:07:49 -0800 Subject: [PATCH 04/20] Fix Dimensions test --- src/NativeModules.js | 9 +-------- tests/integration/apis/Dimensions.test.js | 4 ++-- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/NativeModules.js b/src/NativeModules.js index 370e1e6..7620103 100644 --- a/src/NativeModules.js +++ b/src/NativeModules.js @@ -159,13 +159,6 @@ module.exports = { isTesting: true }, DeviceInfo: { - Dimensions: { - windowPhysicalPixels: { // iPhone 6 - fontScale: 2, - height: 1334, - scale: 2, - width: 750 - } - } + Dimensions: [] } }; diff --git a/tests/integration/apis/Dimensions.test.js b/tests/integration/apis/Dimensions.test.js index bf6f27b..83b4e89 100644 --- a/tests/integration/apis/Dimensions.test.js +++ b/tests/integration/apis/Dimensions.test.js @@ -7,9 +7,9 @@ describe('Dimensions', () => { it('should get dimensions', function () { expect(Dimensions.get('window')).to.deep.equal({ fontScale: 2, - height: 1334, + height: 667, scale: 2, - width: 750 + width: 375 }); }); From 43c045a583c896860ce457070a57f84b49af18be Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 12:26:02 -0800 Subject: [PATCH 05/20] Fix tests for Android progress bar and NativeModules Dimensions --- package.json | 2 +- src/NativeModules.js | 9 ++++++++- tests/integration/components.test.js | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 7779514..a5fa8c7 100644 --- a/package.json +++ b/package.json @@ -59,7 +59,7 @@ "nyc": "10.0.0", "react": "16.0.0-beta.5", "react-dom": "16.0.0-beta.5", - "react-native": "0.49", + "react-native": "0.49.0", "semver": "5.3.0", "sinon-chai": "2.8.0" }, diff --git a/src/NativeModules.js b/src/NativeModules.js index 7620103..8a3488b 100644 --- a/src/NativeModules.js +++ b/src/NativeModules.js @@ -159,6 +159,13 @@ module.exports = { isTesting: true }, DeviceInfo: { - Dimensions: [] + Dimensions: { + windowPhysicalPixels: { + fontScale: 2, + height: 1334, + scale: 2, + width: 750 + } + } } }; diff --git a/tests/integration/components.test.js b/tests/integration/components.test.js index c916779..2adb7ba 100644 --- a/tests/integration/components.test.js +++ b/tests/integration/components.test.js @@ -104,7 +104,7 @@ describe('Components', function () { it('should render ProgressBarAndroid', function () { const { ProgressBarAndroid } = ReactNative; const instance = shallow(); - expect(instance.html()).to.include(' Date: Sun, 5 Nov 2017 12:27:53 -0800 Subject: [PATCH 06/20] Update for RN 0.50 - backwards compatible changes for RN 0.50 - RN 0.50 adds attributes to components and breaks the buildComponentHTML approach to testing --- tests/integration/components.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/integration/components.test.js b/tests/integration/components.test.js index 2adb7ba..bfea9cf 100644 --- a/tests/integration/components.test.js +++ b/tests/integration/components.test.js @@ -23,7 +23,7 @@ describe('Components', function () { it(`should render ${component}`, function () { const Component = ReactNative[component]; const instance = shallow(); - expect(instance.html()).to.equal(buildComponentHTML(component)); + expect(instance.html()).to.include(`<${component}`); }); }); @@ -75,7 +75,7 @@ describe('Components', function () { it('should render KeyboardAvoidingView', function () { const { KeyboardAvoidingView } = ReactNative; const instance = shallow(); - expect(instance.html()).to.equal(buildComponentHTML('View')); + expect(instance.html()).to.include('); expect(instance.html()).to.include('); - expect(instance.html()).to.equal(buildComponentHTML('Text')); + expect(instance.html()).to.include(' Date: Sun, 5 Nov 2017 12:34:43 -0800 Subject: [PATCH 07/20] Package updates - TODO lint fixes --- package.json | 40 ++++++++++++++++++++-------------------- scripts/test-helper.js | 7 ++++--- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index a5fa8c7..431a32d 100644 --- a/package.json +++ b/package.json @@ -33,35 +33,35 @@ }, "homepage": "https://github.com/RealOrangeOne/react-native-mock#readme", "dependencies": { - "enzyme-adapter-react-16": "1.0.2", - "glob": "7.1.1", - "mockery": "2.0.0", + "glob": "7.1.2", + "mockery": "2.1.0", "perfy": "1.1.2", - "promise": "7.1.1", - "regenerator-runtime": "0.10.1", - "sinon": "1.17.7", + "promise": "8.0.1", + "regenerator-runtime": "0.11.0", + "sinon": "2.3.4", "underscore": "1.8.3" }, "devDependencies": { - "babel-cli": "6.9.0", - "chai": "3.5.0", - "chai-as-promised": "6.0.0", + "babel-cli": "6.26.0", + "chai": "4.1.2", + "chai-as-promised": "7.1.1", "enzyme": "3.1.0", - "eslint": "2.10.2", - "eslint-config-airbnb": "9.0.1", - "eslint-plugin-import": "1.8.0", - "eslint-plugin-jsx-a11y": "1.2.2", - "eslint-plugin-react": "5.1.1", - "eslint-plugin-react-native": "1.0.2", - "jsdom": "9.9.1", - "mocha": "3.2.0", + "enzyme-adapter-react-16": "1.0.2", + "eslint": "4.9.0", + "eslint-config-airbnb": "16.1.0", + "eslint-plugin-import": "2.8.0", + "eslint-plugin-jsx-a11y": "6.0.2", + "eslint-plugin-react": "7.4.0", + "eslint-plugin-react-native": "3.1.0", + "jsdom": "11.3.0", + "mocha": "4.0.1", "mocha-assume": "1.0.0", - "nyc": "10.0.0", + "nyc": "11.2.1", "react": "16.0.0-beta.5", "react-dom": "16.0.0-beta.5", "react-native": "0.49.0", - "semver": "5.3.0", - "sinon-chai": "2.8.0" + "semver": "5.4.1", + "sinon-chai": "2.14.0" }, "peerDependencies": { "babel-core": "*", diff --git a/scripts/test-helper.js b/scripts/test-helper.js index ede8982..55769d5 100644 --- a/scripts/test-helper.js +++ b/scripts/test-helper.js @@ -11,11 +11,12 @@ chai.use(sinonChai); chai.use(chaiAsPromised); // Jsdom document & window -const doc = jsdom.jsdom(''); -const win = doc.defaultView; +const { JSDOM } = jsdom; +const dom = new JSDOM(''); +const win = dom.window; // Add to global -global.document = doc; +global.document = win.document; global.window = win; // Add window keys to global window From 4fcf0808bfebb6ee5be2c4c156fcea942612f3f7 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 12:47:50 -0800 Subject: [PATCH 08/20] Automatic lint fixes --- .eslintrc | 7 ++++- scripts/test-helper.js | 1 + src/NativeModules.js | 5 ++-- src/createMockComponent.js | 4 +-- src/haste.js | 8 +++--- src/image-compiler.js | 1 + src/mocks/AsyncStorage.js | 2 +- src/mocks/ListView.js | 16 +++++------ src/mocks/ListViewDataSource.js | 4 +-- src/react-native-mock.js | 2 +- tests/image-compiler.test.js | 2 +- tests/integration/apis/AlertIOS.test.js | 2 +- tests/integration/apis/Easing.test.js | 34 +++++++++++------------ tests/integration/apis/StyleSheet.test.js | 4 +-- tests/mock-component.test.js | 2 +- tests/native-modules.test.js | 4 ++- tests/test-utils.js | 6 ++-- 17 files changed, 54 insertions(+), 50 deletions(-) diff --git a/.eslintrc b/.eslintrc index fe9c11d..ef52fb4 100644 --- a/.eslintrc +++ b/.eslintrc @@ -32,6 +32,11 @@ "ignoreComments": true } ], - "no-multiple-empty-lines": [2, {"max": 3}] + "no-multiple-empty-lines": [2, {"max": 3}], + "import/no-extraneous-dependencies": 0, + "react/jsx-filename-extension": 0, + "import/no-dynamic-require": 0, + "no-multi-assign": 0, + "o-undef": 0, } } diff --git a/scripts/test-helper.js b/scripts/test-helper.js index 55769d5..d9540c7 100644 --- a/scripts/test-helper.js +++ b/scripts/test-helper.js @@ -4,6 +4,7 @@ const chaiAsPromised = require('chai-as-promised'); const jsdom = require('jsdom'); const Enzyme = require('enzyme'); const React16Adapter = require('enzyme-adapter-react-16'); + Enzyme.configure({ adapter: new React16Adapter() }); chai.expect(); diff --git a/src/NativeModules.js b/src/NativeModules.js index 8a3488b..39cc84f 100644 --- a/src/NativeModules.js +++ b/src/NativeModules.js @@ -1,4 +1,5 @@ import sinon from 'sinon'; + const ReactNativeVersion = require('react-native/Libraries/Core/ReactNativeVersion'); module.exports = { @@ -64,11 +65,11 @@ module.exports = { }, IntentAndroid: { openURL: sinon.spy(), - canOpenURL: sinon.spy(url => new Promise((resolve) => resolve(true))) + canOpenURL: sinon.spy(url => new Promise(resolve => resolve(true))) }, LinkingManager: { openURL: sinon.spy(), - canOpenURL: sinon.spy(url => new Promise((resolve) => resolve(true))) + canOpenURL: sinon.spy(url => new Promise(resolve => resolve(true))) }, ModalFullscreenViewManager: {}, Networking: { diff --git a/src/createMockComponent.js b/src/createMockComponent.js index 98719c1..f31117f 100644 --- a/src/createMockComponent.js +++ b/src/createMockComponent.js @@ -1,11 +1,11 @@ import React from 'react'; -export default name => { +export default (name) => { const RealComponent = require(name); const realComponentName = RealComponent.name === 'Component' ? name : RealComponent.name; const componentName = (RealComponent.displayName || realComponentName || name).replace(/^(RCT|RK)/, ''); - const Component = class extends RealComponent { // eslint-disable-line react/prefer-stateless-function + const Component = class extends RealComponent { // eslint-disable-line react/prefer-stateless-function render() { return React.createElement( componentName, diff --git a/src/haste.js b/src/haste.js index 52ca4ed..fc7e3ed 100644 --- a/src/haste.js +++ b/src/haste.js @@ -16,7 +16,7 @@ var PROJECT_NODE_MODULES = path.join(PROJECT_ROOT, 'node_modules'); var TIMER = 'time'; if (!fs.existsSync(PROJECT_NODE_MODULES)) { - PROJECT_NODE_MODULES = path.join(CWD, 'node_modules'); // For tests + PROJECT_NODE_MODULES = path.join(CWD, 'node_modules'); // For tests } perfy.start(TIMER); @@ -32,10 +32,10 @@ _.forEach(files, function (file) { var matches = providesRegex.exec(fs.readFileSync(file).toString()); if (matches && validName.test(matches[1])) { var component = matches[1]; - if (component.match(iosTest) && file.endsWith('.android.js')) { // Dont add IOS components if they end in android.js + if (component.match(iosTest) && file.endsWith('.android.js')) { // Dont add IOS components if they end in android.js return; } - if (component.match(androidTest) && file.endsWith('.ios.js')) { // Dont add Android components if they end in ios.js + if (component.match(androidTest) && file.endsWith('.ios.js')) { // Dont add Android components if they end in ios.js return; } data.hasteMap[component] = file.replace(PROJECT_NODE_MODULES + '/', ''); @@ -47,5 +47,5 @@ fs.writeFileSync(path.join(CWD, 'haste-map.json'), JSON.stringify(data, null, 2) var results = perfy.end(TIMER); if (process.env.NODE_ENV !== 'test') { - console.log(results.summary); // eslint-disable-line no-console + console.log(results.summary); // eslint-disable-line no-console } diff --git a/src/image-compiler.js b/src/image-compiler.js index 58a2b1f..7557275 100644 --- a/src/image-compiler.js +++ b/src/image-compiler.js @@ -4,6 +4,7 @@ */ const m = require('module'); + const originalLoader = m._load; m._load = function hookedLoader(request, parent, isMain) { diff --git a/src/mocks/AsyncStorage.js b/src/mocks/AsyncStorage.js index f576f49..b8e58e0 100644 --- a/src/mocks/AsyncStorage.js +++ b/src/mocks/AsyncStorage.js @@ -1,4 +1,4 @@ -const AsyncStorage = require('AsyncStorage'); // eslint-disable-line import/no-unresolved +const AsyncStorage = require('AsyncStorage'); // eslint-disable-line import/no-unresolved let _data = {}; diff --git a/src/mocks/ListView.js b/src/mocks/ListView.js index 9f1bce8..f3c625e 100644 --- a/src/mocks/ListView.js +++ b/src/mocks/ListView.js @@ -11,7 +11,7 @@ /* eslint-disable react/prop-types */ const React = require('react'); -const ScrollView = require('ScrollView'); // eslint-disable-line import/no-unresolved +const ScrollView = require('ScrollView'); // eslint-disable-line import/no-unresolved const StaticRenderer = require('StaticRenderer'); // eslint-disable-line import/no-unresolved const View = require('View'); // eslint-disable-line import/no-unresolved @@ -29,18 +29,16 @@ class ListViewMock extends React.Component { const rowIDs = allRowIDs[sectionIdx]; for (let rowIdx = 0; rowIdx < rowIDs.length; rowIdx++) { const rowID = rowIDs[rowIdx]; - rows.push( - - ); + />); } } @@ -55,7 +53,7 @@ class ListViewMock extends React.Component { } ListViewMock.defaultProps = { - renderScrollComponent: (props) => + renderScrollComponent: props => }; ListViewMock.DataSource = require('ListViewDataSource'); // eslint-disable-line import/no-unresolved diff --git a/src/mocks/ListViewDataSource.js b/src/mocks/ListViewDataSource.js index c12cd6f..fcbda9b 100644 --- a/src/mocks/ListViewDataSource.js +++ b/src/mocks/ListViewDataSource.js @@ -1,11 +1,11 @@ -const DataSource = require('ListViewDataSource'); // eslint-disable-line import/no-unresolved +const DataSource = require('ListViewDataSource'); // eslint-disable-line import/no-unresolved DataSource.prototype.toJSON = function () { function ListViewDataSource(dataBlob) { this.items = 0; // Ensure this doesn't throw. try { - Object.keys(dataBlob).forEach(key => { + Object.keys(dataBlob).forEach((key) => { this.items += dataBlob[key] && ( dataBlob[key].length || dataBlob[key].size || 0 ); diff --git a/src/react-native-mock.js b/src/react-native-mock.js index f62ea21..43337a5 100644 --- a/src/react-native-mock.js +++ b/src/react-native-mock.js @@ -33,7 +33,7 @@ mockery.registerMock('ensureComponentIsNative', () => true); mockery.registerMock('requireNativeComponent', sinon.spy(viewName => props => React.createElement( viewName, props, - props.children // eslint-disable-line react/prop-types + props.children // eslint-disable-line react/prop-types ))); mockery.registerMock('ErrorUtils', require('./mocks/ErrorUtils')); diff --git a/tests/image-compiler.test.js b/tests/image-compiler.test.js index db385e8..c1ed71a 100644 --- a/tests/image-compiler.test.js +++ b/tests/image-compiler.test.js @@ -3,7 +3,7 @@ import { expect } from 'chai'; describe('Image Compiler', function () { it('should require a jpg image', function () { - expect(require('foo.jpg')).to.deep.equal({ uri: 'foo.jpg' }); // eslint-disable-line import/no-unresolved + expect(require('foo.jpg')).to.deep.equal({ uri: 'foo.jpg' }); // eslint-disable-line import/no-unresolved }); it('should require a jpeg image', function () { diff --git a/tests/integration/apis/AlertIOS.test.js b/tests/integration/apis/AlertIOS.test.js index cdd4f8e..402a56f 100644 --- a/tests/integration/apis/AlertIOS.test.js +++ b/tests/integration/apis/AlertIOS.test.js @@ -36,7 +36,7 @@ describe('AlertIOS', () => { }, { text: 'OK', - onPress: password => {} + onPress: (password) => {} } ], 'secure-text' diff --git a/tests/integration/apis/Easing.test.js b/tests/integration/apis/Easing.test.js index 1c1e6c0..44e31e7 100644 --- a/tests/integration/apis/Easing.test.js +++ b/tests/integration/apis/Easing.test.js @@ -116,23 +116,23 @@ describe('Easing', () => { } const SAMPLES = { - in_quad: [0, 0.0030864197530864196, 0.012345679012345678, 0.027777777777777776, 0.04938271604938271, 0.0771604938271605, 0.1111111111111111, 0.15123456790123457, 0.19753086419753085, 0.25, 0.308641975308642, 0.37345679012345684, 0.4444444444444444, 0.5216049382716049, 0.6049382716049383, 0.6944444444444445, 0.7901234567901234, 0.8919753086419753, 1], // eslint-disable-line max-len - out_quad: [0, 0.10802469135802469, 0.20987654320987653, 0.3055555555555555, 0.3950617283950617, 0.47839506172839513, 0.5555555555555556, 0.6265432098765432, 0.691358024691358, 0.75, 0.8024691358024691, 0.8487654320987654, 0.888888888888889, 0.9228395061728394, 0.9506172839506174, 0.9722222222222221, 0.9876543209876543, 0.9969135802469136, 1], // eslint-disable-line max-len - inOut_quad: [0, 0.006172839506172839, 0.024691358024691357, 0.05555555555555555, 0.09876543209876543, 0.154320987654321, 0.2222222222222222, 0.30246913580246915, 0.3950617283950617, 0.5, 0.6049382716049383, 0.697530864197531, 0.7777777777777777, 0.845679012345679, 0.9012345679012346, 0.9444444444444444, 0.9753086419753086, 0.9938271604938271, 1], // eslint-disable-line max-len - in_cubic: [0, 0.00017146776406035664, 0.0013717421124828531, 0.004629629629629629, 0.010973936899862825, 0.021433470507544586, 0.037037037037037035, 0.05881344307270234, 0.0877914951989026, 0.125, 0.1714677640603567, 0.22822359396433475, 0.2962962962962963, 0.37671467764060357, 0.4705075445816187, 0.5787037037037038, 0.7023319615912208, 0.8424211248285322, 1], // eslint-disable-line max-len - out_cubic: [0, 0.15757887517146785, 0.2976680384087792, 0.42129629629629617, 0.5294924554183813, 0.6232853223593964, 0.7037037037037036, 0.7717764060356652, 0.8285322359396433, 0.875, 0.9122085048010974, 0.9411865569272977, 0.9629629629629629, 0.9785665294924554, 0.9890260631001372, 0.9953703703703703, 0.9986282578875172, 0.9998285322359396, 1], // eslint-disable-line max-len - inOut_cubic: [0, 0.0006858710562414266, 0.0054869684499314125, 0.018518518518518517, 0.0438957475994513, 0.08573388203017834, 0.14814814814814814, 0.23525377229080935, 0.3511659807956104, 0.5, 0.6488340192043895, 0.7647462277091908, 0.8518518518518519, 0.9142661179698217, 0.9561042524005487, 0.9814814814814815, 0.9945130315500685, 0.9993141289437586, 1], // eslint-disable-line max-len - in_sin: [0, 0.003805301908254455, 0.01519224698779198, 0.03407417371093169, 0.06030737921409157, 0.09369221296335006, 0.1339745962155613, 0.1808479557110082, 0.233955556881022, 0.2928932188134524, 0.35721239031346064, 0.42642356364895384, 0.4999999999999999, 0.5773817382593005, 0.6579798566743311, 0.7411809548974793, 0.8263518223330696, 0.9128442572523416, 0.9999999999999999], // eslint-disable-line max-len - out_sin: [0, 0.08715574274765817, 0.17364817766693033, 0.25881904510252074, 0.3420201433256687, 0.42261826174069944, 0.49999999999999994, 0.573576436351046, 0.6427876096865393, 0.7071067811865475, 0.766044443118978, 0.8191520442889918, 0.8660254037844386, 0.9063077870366499, 0.9396926207859083, 0.9659258262890683, 0.984807753012208, 0.9961946980917455, 1], // eslint-disable-line max-len - inOut_sin: [0, 0.00759612349389599, 0.030153689607045786, 0.06698729810778065, 0.116977778440511, 0.17860619515673032, 0.24999999999999994, 0.32898992833716556, 0.4131759111665348, 0.49999999999999994, 0.5868240888334652, 0.6710100716628343, 0.7499999999999999, 0.8213938048432696, 0.883022221559489, 0.9330127018922194, 0.9698463103929542, 0.9924038765061041, 1], // eslint-disable-line max-len - in_exp: [0, 0.0014352875901128893, 0.002109491677524035, 0.0031003926796253885, 0.004556754060844206, 0.006697218616039631, 0.009843133202303688, 0.014466792379488908, 0.021262343752724643, 0.03125, 0.045929202883612456, 0.06750373368076916, 0.09921256574801243, 0.1458161299470146, 0.2143109957132682, 0.31498026247371835, 0.46293735614364506, 0.6803950000871883, 1], // eslint-disable-line max-len - out_exp: [0, 0.31960499991281155, 0.5370626438563548, 0.6850197375262816, 0.7856890042867318, 0.8541838700529854, 0.9007874342519875, 0.9324962663192309, 0.9540707971163875, 0.96875, 0.9787376562472754, 0.9855332076205111, 0.9901568667976963, 0.9933027813839603, 0.9954432459391558, 0.9968996073203746, 0.9978905083224759, 0.9985647124098871, 1], // eslint-disable-line max-len - inOut_exp: [0, 0.0010547458387620175, 0.002278377030422103, 0.004921566601151844, 0.010631171876362321, 0.022964601441806228, 0.049606282874006216, 0.1071554978566341, 0.23146867807182253, 0.5, 0.7685313219281775, 0.892844502143366, 0.9503937171259937, 0.9770353985581938, 0.9893688281236377, 0.9950784333988482, 0.9977216229695779, 0.998945254161238, 1], // eslint-disable-line max-len - in_circle: [0, 0.0015444024660317135, 0.006192010000093506, 0.013986702816730645, 0.025003956956430873, 0.03935464078941209, 0.057190958417936644, 0.07871533601238889, 0.10419358352238339, 0.1339745962155614, 0.1685205807169019, 0.20845517506805522, 0.2546440075000701, 0.3083389112228482, 0.37146063894529113, 0.4472292016074334, 0.5418771527091488, 0.6713289009389102, 1], // eslint-disable-line max-len - out_circle: [0, 0.3286710990610898, 0.45812284729085123, 0.5527707983925666, 0.6285393610547089, 0.6916610887771518, 0.7453559924999298, 0.7915448249319448, 0.8314794192830981, 0.8660254037844386, 0.8958064164776166, 0.9212846639876111, 0.9428090415820634, 0.9606453592105879, 0.9749960430435691, 0.9860132971832694, 0.9938079899999065, 0.9984555975339683, 1], // eslint-disable-line max-len - inOut_circle: [0, 0.003096005000046753, 0.012501978478215436, 0.028595479208968322, 0.052096791761191696, 0.08426029035845095, 0.12732200375003505, 0.18573031947264557, 0.2709385763545744, 0.5, 0.7290614236454256, 0.8142696805273546, 0.8726779962499649, 0.915739709641549, 0.9479032082388084, 0.9714045207910317, 0.9874980215217846, 0.9969039949999532, 1], // eslint-disable-line max-len - in_back_: [0, -0.004788556241426612, -0.017301289437585736, -0.0347587962962963, -0.05438167352537723, -0.07339051783264748, -0.08900592592592595, -0.09844849451303156, -0.0989388203017833, -0.08769750000000004, -0.06194513031550073, -0.018902307956104283, 0.044210370370370254, 0.13017230795610413, 0.2417629080932785, 0.3817615740740742, 0.5529477091906719, 0.7581007167352535, 0.9999999999999998], // eslint-disable-line max-len - out_back_: [2.220446049250313e-16, 0.24189928326474652, 0.44705229080932807, 0.6182384259259258, 0.7582370919067215, 0.8698276920438959, 0.9557896296296297, 1.0189023079561044, 1.0619451303155008, 1.0876975, 1.0989388203017834, 1.0984484945130315, 1.089005925925926, 1.0733905178326475, 1.0543816735253773, 1.0347587962962963, 1.0173012894375857, 1.0047885562414267, 1] // eslint-disable-line max-len + in_quad: [0, 0.0030864197530864196, 0.012345679012345678, 0.027777777777777776, 0.04938271604938271, 0.0771604938271605, 0.1111111111111111, 0.15123456790123457, 0.19753086419753085, 0.25, 0.308641975308642, 0.37345679012345684, 0.4444444444444444, 0.5216049382716049, 0.6049382716049383, 0.6944444444444445, 0.7901234567901234, 0.8919753086419753, 1], // eslint-disable-line max-len + out_quad: [0, 0.10802469135802469, 0.20987654320987653, 0.3055555555555555, 0.3950617283950617, 0.47839506172839513, 0.5555555555555556, 0.6265432098765432, 0.691358024691358, 0.75, 0.8024691358024691, 0.8487654320987654, 0.888888888888889, 0.9228395061728394, 0.9506172839506174, 0.9722222222222221, 0.9876543209876543, 0.9969135802469136, 1], // eslint-disable-line max-len + inOut_quad: [0, 0.006172839506172839, 0.024691358024691357, 0.05555555555555555, 0.09876543209876543, 0.154320987654321, 0.2222222222222222, 0.30246913580246915, 0.3950617283950617, 0.5, 0.6049382716049383, 0.697530864197531, 0.7777777777777777, 0.845679012345679, 0.9012345679012346, 0.9444444444444444, 0.9753086419753086, 0.9938271604938271, 1], // eslint-disable-line max-len + in_cubic: [0, 0.00017146776406035664, 0.0013717421124828531, 0.004629629629629629, 0.010973936899862825, 0.021433470507544586, 0.037037037037037035, 0.05881344307270234, 0.0877914951989026, 0.125, 0.1714677640603567, 0.22822359396433475, 0.2962962962962963, 0.37671467764060357, 0.4705075445816187, 0.5787037037037038, 0.7023319615912208, 0.8424211248285322, 1], // eslint-disable-line max-len + out_cubic: [0, 0.15757887517146785, 0.2976680384087792, 0.42129629629629617, 0.5294924554183813, 0.6232853223593964, 0.7037037037037036, 0.7717764060356652, 0.8285322359396433, 0.875, 0.9122085048010974, 0.9411865569272977, 0.9629629629629629, 0.9785665294924554, 0.9890260631001372, 0.9953703703703703, 0.9986282578875172, 0.9998285322359396, 1], // eslint-disable-line max-len + inOut_cubic: [0, 0.0006858710562414266, 0.0054869684499314125, 0.018518518518518517, 0.0438957475994513, 0.08573388203017834, 0.14814814814814814, 0.23525377229080935, 0.3511659807956104, 0.5, 0.6488340192043895, 0.7647462277091908, 0.8518518518518519, 0.9142661179698217, 0.9561042524005487, 0.9814814814814815, 0.9945130315500685, 0.9993141289437586, 1], // eslint-disable-line max-len + in_sin: [0, 0.003805301908254455, 0.01519224698779198, 0.03407417371093169, 0.06030737921409157, 0.09369221296335006, 0.1339745962155613, 0.1808479557110082, 0.233955556881022, 0.2928932188134524, 0.35721239031346064, 0.42642356364895384, 0.4999999999999999, 0.5773817382593005, 0.6579798566743311, 0.7411809548974793, 0.8263518223330696, 0.9128442572523416, 0.9999999999999999], // eslint-disable-line max-len + out_sin: [0, 0.08715574274765817, 0.17364817766693033, 0.25881904510252074, 0.3420201433256687, 0.42261826174069944, 0.49999999999999994, 0.573576436351046, 0.6427876096865393, 0.7071067811865475, 0.766044443118978, 0.8191520442889918, 0.8660254037844386, 0.9063077870366499, 0.9396926207859083, 0.9659258262890683, 0.984807753012208, 0.9961946980917455, 1], // eslint-disable-line max-len + inOut_sin: [0, 0.00759612349389599, 0.030153689607045786, 0.06698729810778065, 0.116977778440511, 0.17860619515673032, 0.24999999999999994, 0.32898992833716556, 0.4131759111665348, 0.49999999999999994, 0.5868240888334652, 0.6710100716628343, 0.7499999999999999, 0.8213938048432696, 0.883022221559489, 0.9330127018922194, 0.9698463103929542, 0.9924038765061041, 1], // eslint-disable-line max-len + in_exp: [0, 0.0014352875901128893, 0.002109491677524035, 0.0031003926796253885, 0.004556754060844206, 0.006697218616039631, 0.009843133202303688, 0.014466792379488908, 0.021262343752724643, 0.03125, 0.045929202883612456, 0.06750373368076916, 0.09921256574801243, 0.1458161299470146, 0.2143109957132682, 0.31498026247371835, 0.46293735614364506, 0.6803950000871883, 1], // eslint-disable-line max-len + out_exp: [0, 0.31960499991281155, 0.5370626438563548, 0.6850197375262816, 0.7856890042867318, 0.8541838700529854, 0.9007874342519875, 0.9324962663192309, 0.9540707971163875, 0.96875, 0.9787376562472754, 0.9855332076205111, 0.9901568667976963, 0.9933027813839603, 0.9954432459391558, 0.9968996073203746, 0.9978905083224759, 0.9985647124098871, 1], // eslint-disable-line max-len + inOut_exp: [0, 0.0010547458387620175, 0.002278377030422103, 0.004921566601151844, 0.010631171876362321, 0.022964601441806228, 0.049606282874006216, 0.1071554978566341, 0.23146867807182253, 0.5, 0.7685313219281775, 0.892844502143366, 0.9503937171259937, 0.9770353985581938, 0.9893688281236377, 0.9950784333988482, 0.9977216229695779, 0.998945254161238, 1], // eslint-disable-line max-len + in_circle: [0, 0.0015444024660317135, 0.006192010000093506, 0.013986702816730645, 0.025003956956430873, 0.03935464078941209, 0.057190958417936644, 0.07871533601238889, 0.10419358352238339, 0.1339745962155614, 0.1685205807169019, 0.20845517506805522, 0.2546440075000701, 0.3083389112228482, 0.37146063894529113, 0.4472292016074334, 0.5418771527091488, 0.6713289009389102, 1], // eslint-disable-line max-len + out_circle: [0, 0.3286710990610898, 0.45812284729085123, 0.5527707983925666, 0.6285393610547089, 0.6916610887771518, 0.7453559924999298, 0.7915448249319448, 0.8314794192830981, 0.8660254037844386, 0.8958064164776166, 0.9212846639876111, 0.9428090415820634, 0.9606453592105879, 0.9749960430435691, 0.9860132971832694, 0.9938079899999065, 0.9984555975339683, 1], // eslint-disable-line max-len + inOut_circle: [0, 0.003096005000046753, 0.012501978478215436, 0.028595479208968322, 0.052096791761191696, 0.08426029035845095, 0.12732200375003505, 0.18573031947264557, 0.2709385763545744, 0.5, 0.7290614236454256, 0.8142696805273546, 0.8726779962499649, 0.915739709641549, 0.9479032082388084, 0.9714045207910317, 0.9874980215217846, 0.9969039949999532, 1], // eslint-disable-line max-len + in_back_: [0, -0.004788556241426612, -0.017301289437585736, -0.0347587962962963, -0.05438167352537723, -0.07339051783264748, -0.08900592592592595, -0.09844849451303156, -0.0989388203017833, -0.08769750000000004, -0.06194513031550073, -0.018902307956104283, 0.044210370370370254, 0.13017230795610413, 0.2417629080932785, 0.3817615740740742, 0.5529477091906719, 0.7581007167352535, 0.9999999999999998], // eslint-disable-line max-len + out_back_: [2.220446049250313e-16, 0.24189928326474652, 0.44705229080932807, 0.6182384259259258, 0.7582370919067215, 0.8698276920438959, 0.9557896296296297, 1.0189023079561044, 1.0619451303155008, 1.0876975, 1.0989388203017834, 1.0984484945130315, 1.089005925925926, 1.0733905178326475, 1.0543816735253773, 1.0347587962962963, 1.0173012894375857, 1.0047885562414267, 1] // eslint-disable-line max-len }; Object.keys(SAMPLES).forEach(function (type) { diff --git a/tests/integration/apis/StyleSheet.test.js b/tests/integration/apis/StyleSheet.test.js index 3a5dcf1..94be83e 100644 --- a/tests/integration/apis/StyleSheet.test.js +++ b/tests/integration/apis/StyleSheet.test.js @@ -46,9 +46,7 @@ describe('StyleSheet', () => { }); it('should flatten with nested array', () => { - const result = StyleSheet.flatten( - [styles.listItem, [styles.headerItem, styles.selectedListItem]] - ); + const result = StyleSheet.flatten([styles.listItem, [styles.headerItem, styles.selectedListItem]]); expect(result).to.deep.equal({ flex: 1, fontSize: 16, diff --git a/tests/mock-component.test.js b/tests/mock-component.test.js index 44c5585..43a4c55 100644 --- a/tests/mock-component.test.js +++ b/tests/mock-component.test.js @@ -45,7 +45,7 @@ describe('Mock Component', function () { }); it('should be accessible globally', function () { - const RequiredComponent = require('requireNativeComponent')('test'); // eslint-disable-line import/no-unresolved + const RequiredComponent = require('requireNativeComponent')('test'); // eslint-disable-line import/no-unresolved const Component = createMockComponent('test'); expect(shallow().html()).to.equal(shallow().html()); }); diff --git a/tests/native-modules.test.js b/tests/native-modules.test.js index e554f87..e6149ff 100644 --- a/tests/native-modules.test.js +++ b/tests/native-modules.test.js @@ -1,12 +1,14 @@ import { expect } from 'chai'; + const NativeModules = require('../src/NativeModules'); + import sinon from 'sinon'; import { expectSpy } from './test-utils'; describe('Native Modules', function () { it('Should be defined', function () { expect(NativeModules).to.be.an('object'); - expect(Object.keys(require('NativeModules'))).to.deep.equal(Object.keys(NativeModules)); // eslint-disable-line import/no-unresolved + expect(Object.keys(require('NativeModules'))).to.deep.equal(Object.keys(NativeModules)); // eslint-disable-line import/no-unresolved }); it('should be requirable', function () { diff --git a/tests/test-utils.js b/tests/test-utils.js index e51a116..cf20cf6 100644 --- a/tests/test-utils.js +++ b/tests/test-utils.js @@ -2,12 +2,10 @@ import { expect } from 'chai'; import sinon from 'sinon'; import semver from 'semver'; -export const buildComponentHTML = (componentName) => `<${componentName}>`; +export const buildComponentHTML = componentName => `<${componentName}>`; export const expectSpy = function isSpy(spy) { - expect(spy).to.contain.all.keys( - Object.keys(sinon.spy()) - ); + expect(spy).to.contain.all.keys(Object.keys(sinon.spy())); expect(spy.id).to.contain('spy'); expect(spy.callCount).to.be.a('number'); expect(spy.called).to.be.a('boolean'); From a15c31ee74069e5294182c0e7bbd970d692742f4 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 12:53:20 -0800 Subject: [PATCH 09/20] Manual lint fixes --- scripts/test-helper.js | 4 ++-- src/mocks/ListView.js | 4 ++-- src/react-native-mock.js | 5 +++-- tests/integration/apis/Easing.test.js | 24 ++++++++++++------------ tests/integration/components.test.js | 2 +- tests/native-modules.test.js | 6 +++--- tests/no-import.test.js | 2 +- 7 files changed, 24 insertions(+), 23 deletions(-) diff --git a/scripts/test-helper.js b/scripts/test-helper.js index d9540c7..7830cb9 100644 --- a/scripts/test-helper.js +++ b/scripts/test-helper.js @@ -21,9 +21,9 @@ global.document = win.document; global.window = win; // Add window keys to global window -Object.keys(window).forEach((key) => { +Object.keys(window).forEach((key) => { // eslint-disable-line no-undef if (!(key in global)) { - global[key] = window[key]; + global[key] = window[key]; // eslint-disable-line no-undef } }); diff --git a/src/mocks/ListView.js b/src/mocks/ListView.js index f3c625e..e2d96f5 100644 --- a/src/mocks/ListView.js +++ b/src/mocks/ListView.js @@ -24,10 +24,10 @@ class ListViewMock extends React.Component { const { dataSource, renderFooter, renderHeader } = this.props; const rows = [renderHeader && renderHeader()]; const allRowIDs = dataSource.rowIdentities; - for (let sectionIdx = 0; sectionIdx < allRowIDs.length; sectionIdx++) { + for (let sectionIdx = 0; sectionIdx < allRowIDs.length; sectionIdx += 1) { const sectionID = dataSource.sectionIdentities[sectionIdx]; const rowIDs = allRowIDs[sectionIdx]; - for (let rowIdx = 0; rowIdx < rowIDs.length; rowIdx++) { + for (let rowIdx = 0; rowIdx < rowIDs.length; rowIdx += 1) { const rowID = rowIDs[rowIdx]; rows.push( { const { Easing } = require('react-native'); - it('should have all functions', function () { + it('should have all functions', () => { expect(Easing.step0).to.be.a('function'); expect(Easing.step1).to.be.a('function'); expect(Easing.linear).to.be.a('function'); @@ -34,8 +34,8 @@ describe('Easing', () => { expect(Easing.inOut).to.be.a('function'); }); - describe('linear', function () { - it('should work', function () { + describe('linear', () => { + it('should work', () => { const easing = Easing.linear; expect(easing(0)).to.equal(0); @@ -44,7 +44,7 @@ describe('Easing', () => { expect(easing(1)).to.equal(1); }); - it('should work with ease in', function () { + it('should work with ease in', () => { const easing = Easing.in(Easing.linear); expect(easing(0)).to.equal(0); expect(easing(0.5)).to.equal(0.5); @@ -52,7 +52,7 @@ describe('Easing', () => { expect(easing(1)).to.equal(1); }); - it('should work with ease out', function () { + it('should work with ease out', () => { const easing = Easing.out(Easing.linear); expect(easing(0)).to.equal(0); expect(easing(0.5)).to.equal(0.5); @@ -61,7 +61,7 @@ describe('Easing', () => { }); }); - describe('quad', function () { + describe('quad', () => { it('should work with ease in', () => { function easeInQuad(t) { return t * t; @@ -87,7 +87,7 @@ describe('Easing', () => { if (t < 1) { return 0.5 * t * t; } - return -((t - 1) * (t - 3) - 1) / 2; + return -(((t - 1) * (t - 3)) - 1) / 2; } const easing = Easing.inOut(Easing.quad); for (let t = -0.5; t < 1.5; t += 0.1) { @@ -104,12 +104,12 @@ describe('Easing', () => { } }); - describe('samples', function () { + describe('samples', () => { function sampleEasingFunction(easing) { const DURATION = 300; - const tickCount = Math.round(DURATION * 60 / 1000); + const tickCount = Math.round((DURATION * 60) / 1000); const samples = []; - for (let i = 0; i <= tickCount; i++) { + for (let i = 0; i <= tickCount; i += 1) { samples.push(easing(i / tickCount)); } return samples; @@ -135,8 +135,8 @@ describe('Easing', () => { out_back_: [2.220446049250313e-16, 0.24189928326474652, 0.44705229080932807, 0.6182384259259258, 0.7582370919067215, 0.8698276920438959, 0.9557896296296297, 1.0189023079561044, 1.0619451303155008, 1.0876975, 1.0989388203017834, 1.0984484945130315, 1.089005925925926, 1.0733905178326475, 1.0543816735253773, 1.0347587962962963, 1.0173012894375857, 1.0047885562414267, 1] // eslint-disable-line max-len }; - Object.keys(SAMPLES).forEach(function (type) { - it('should ease ' + type, function () { + Object.keys(SAMPLES).forEach((type) => { + it(`should ease ${type}`, () => { const [modeName, easingName, isFunction] = type.split('_'); let easing = Easing[easingName]; if (isFunction !== undefined) { diff --git a/tests/integration/components.test.js b/tests/integration/components.test.js index bfea9cf..078d7b1 100644 --- a/tests/integration/components.test.js +++ b/tests/integration/components.test.js @@ -1,8 +1,8 @@ import React from 'react'; // eslint-disable-line no-unused-vars import { shallow } from 'enzyme'; import { expect } from 'chai'; -import { buildComponentHTML } from '../test-utils'; import sinon from 'sinon'; +import { buildComponentHTML } from '../test-utils'; const COMPONENTS = [ 'Image', diff --git a/tests/native-modules.test.js b/tests/native-modules.test.js index e6149ff..0e7a6dd 100644 --- a/tests/native-modules.test.js +++ b/tests/native-modules.test.js @@ -1,10 +1,10 @@ import { expect } from 'chai'; - -const NativeModules = require('../src/NativeModules'); - import sinon from 'sinon'; + import { expectSpy } from './test-utils'; +const NativeModules = require('../src/NativeModules'); + describe('Native Modules', function () { it('Should be defined', function () { expect(NativeModules).to.be.an('object'); diff --git a/tests/no-import.test.js b/tests/no-import.test.js index 62987cd..dcf9418 100644 --- a/tests/no-import.test.js +++ b/tests/no-import.test.js @@ -8,7 +8,7 @@ describe('React-Native-Mock import', function () { }); it('should happen when requiring react-native-mock', function () { - const main = require('../package.json').main; + const { main } = require('../package.json'); expect(() => require(path.join('..', main))).to.throw; }); }); From e7b2d1576d43eaced57697fe0ac0614f2a2cc324 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 12:53:52 -0800 Subject: [PATCH 10/20] Fix test broken by chai upgrade - remove unnecessary assertion because it's asserted implicitly in the next assertion --- tests/integration/components.test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/integration/components.test.js b/tests/integration/components.test.js index 078d7b1..4acd618 100644 --- a/tests/integration/components.test.js +++ b/tests/integration/components.test.js @@ -55,7 +55,6 @@ describe('Components', function () { it('should have DrawerLayoutAndroid with static properties for the positions', () => { const { DrawerLayoutAndroid } = ReactNative; - expect(DrawerLayoutAndroid.positions).to.be.an.object; expect(DrawerLayoutAndroid.positions).to.deep.equal({ Left: 'LEFT', Right: 'RIGHT' From 36f18eac31e2ed6f4bcbeb1657d269f663c68ec8 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 12:56:00 -0800 Subject: [PATCH 11/20] More package updates --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 431a32d..4e5bed0 100644 --- a/package.json +++ b/package.json @@ -38,16 +38,16 @@ "perfy": "1.1.2", "promise": "8.0.1", "regenerator-runtime": "0.11.0", - "sinon": "2.3.4", + "sinon": "4.1.1", "underscore": "1.8.3" }, "devDependencies": { "babel-cli": "6.26.0", "chai": "4.1.2", "chai-as-promised": "7.1.1", - "enzyme": "3.1.0", - "enzyme-adapter-react-16": "1.0.2", - "eslint": "4.9.0", + "enzyme": "3.1.1", + "enzyme-adapter-react-16": "1.0.4", + "eslint": "4.10.0", "eslint-config-airbnb": "16.1.0", "eslint-plugin-import": "2.8.0", "eslint-plugin-jsx-a11y": "6.0.2", @@ -56,7 +56,7 @@ "jsdom": "11.3.0", "mocha": "4.0.1", "mocha-assume": "1.0.0", - "nyc": "11.2.1", + "nyc": "11.3.0", "react": "16.0.0-beta.5", "react-dom": "16.0.0-beta.5", "react-native": "0.49.0", From 014cde792ac07110fc8a503b69df4133038a6eed Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 13:19:16 -0800 Subject: [PATCH 12/20] Update travis to test RN 0.49+ Signed-off-by: Jason Ma --- .travis.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 64ff5de..c3bf2cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,12 +8,8 @@ node_js: # values taken from react-native's package.json env: - - REACT_NATIVE_VERSION=0.38 REACT_VERSION=15.4.0 - - REACT_NATIVE_VERSION=0.39 REACT_VERSION=15.4.0-rc.4 - - REACT_NATIVE_VERSION=0.40 REACT_VERSION=15.4.1 - - REACT_NATIVE_VERSION=0.41 REACT_VERSION=15.4.0 - - REACT_NATIVE_VERSION=0.42 REACT_VERSION=15.4.1 - - REACT_NATIVE_VERSION=0.43 REACT_VERSION=16.0.0-alpha.6 + - REACT_NATIVE_VERSION=0.49 REACT_VERSION=16.0.0-beta.5 + - REACT_NATIVE_VERSION=0.50 REACT_VERSION=16.0.0 before_script: From 6aa78409bf2881827e7dead0819d0bd2136d81e3 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 18:33:49 -0800 Subject: [PATCH 13/20] Remove react-addons-test-utils from travis builds --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c3bf2cb..dffa20c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,5 +14,5 @@ env: before_script: - npm uninstall react-native react react-dom react-addons-test-utils - - npm install react@~$REACT_VERSION react-dom@~$REACT_VERSION react-addons-test-utils@~$REACT_VERSION react-native@~$REACT_NATIVE_VERSION + - npm install react@~$REACT_VERSION react-dom@~$REACT_VERSION react-native@~$REACT_NATIVE_VERSION - npm run build-haste From f1b2f25df218a3d467c59ede306183afe6fff272 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 19:01:51 -0800 Subject: [PATCH 14/20] Use RN 0.50+ - render of `ProgressBarAndroid` changed from `ActivityIndicator` in RN 0.49 back to `AndroidProgressBar` in RN 0.50 Signed-off-by: Jason Ma --- .travis.yml | 1 - package.json | 9 +++------ 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index dffa20c..d176a1d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,6 @@ node_js: # values taken from react-native's package.json env: - - REACT_NATIVE_VERSION=0.49 REACT_VERSION=16.0.0-beta.5 - REACT_NATIVE_VERSION=0.50 REACT_VERSION=16.0.0 diff --git a/package.json b/package.json index 4e5bed0..7685433 100644 --- a/package.json +++ b/package.json @@ -57,17 +57,14 @@ "mocha": "4.0.1", "mocha-assume": "1.0.0", "nyc": "11.3.0", - "react": "16.0.0-beta.5", - "react-dom": "16.0.0-beta.5", - "react-native": "0.49.0", "semver": "5.4.1", "sinon-chai": "2.14.0" }, "peerDependencies": { "babel-core": "*", "babel-preset-react-native": "*", - "react": ">=16.0.0-beta.5", - "react-dom": ">=16.0.0-beta.5", - "react-native": ">=0.49.0" + "react": ">=16.0.0", + "react-dom": ">=16.0.0", + "react-native": ">=0.50.0" } } From 9d8ff3b821cebb3c8dce39e4e471a33b495f531a Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 19:03:26 -0800 Subject: [PATCH 15/20] Add tests for Node 8 now that it's LTS Signed-off-by: Jason Ma --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index d176a1d..7ec4939 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: - "6.0.0" - "4" - "6" + - "8" # values taken from react-native's package.json From 669d461effff5c62462d24af0cc2170dffc0142e Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 19:08:41 -0800 Subject: [PATCH 16/20] Add back devDeps for RN and react to fix build Signed-off-by: Jason Ma --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index 7685433..bc2ccaf 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,9 @@ "mocha": "4.0.1", "mocha-assume": "1.0.0", "nyc": "11.3.0", + "react": "16.0.0", + "react-dom": "16.0.0", + "react-native": "0.50.0", "semver": "5.4.1", "sinon-chai": "2.14.0" }, From ad2ced5831d63de034ee8add7d44516083d2ea04 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 19:12:30 -0800 Subject: [PATCH 17/20] Fix CI to not rely on devDeps react and react-native Signed-off-by: Jason Ma --- .travis.yml | 4 ++-- package.json | 3 --- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7ec4939..b0602ac 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ node_js: env: - REACT_NATIVE_VERSION=0.50 REACT_VERSION=16.0.0 +before_install: + - npm install react@~$REACT_VERSION react-dom@~$REACT_VERSION react-native@~$REACT_NATIVE_VERSION before_script: - - npm uninstall react-native react react-dom react-addons-test-utils - - npm install react@~$REACT_VERSION react-dom@~$REACT_VERSION react-native@~$REACT_NATIVE_VERSION - npm run build-haste diff --git a/package.json b/package.json index bc2ccaf..7685433 100644 --- a/package.json +++ b/package.json @@ -57,9 +57,6 @@ "mocha": "4.0.1", "mocha-assume": "1.0.0", "nyc": "11.3.0", - "react": "16.0.0", - "react-dom": "16.0.0", - "react-native": "0.50.0", "semver": "5.4.1", "sinon-chai": "2.14.0" }, From 9d48815401dafac6a20ea8774a380d928fba905f Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sun, 5 Nov 2017 19:14:39 -0800 Subject: [PATCH 18/20] Drop support for Node 4 Signed-off-by: Jason Ma --- .travis.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index b0602ac..d3a3a65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,6 @@ language: node_js node_js: - - "4.0.0" - "6.0.0" - - "4" - "6" - "8" From e70acd5a49f75c8dae4e962a65760047e144dc92 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sat, 6 Jan 2018 11:29:57 -0800 Subject: [PATCH 19/20] Node support - Update readme to reference Node 6 support - Update travis to include Node 8.0.0 tests --- .travis.yml | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d3a3a65..3ae10f1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,7 @@ language: node_js node_js: - "6.0.0" - "6" + - "8.0.0" - "8" diff --git a/README.md b/README.md index f84e2da..541723c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ A fully mocked and test-friendly version of react native ## Requirements -- Node.js 4+ +- Node.js 6+ (dropping support for Node 4 as some dev dependencies don't support it) - The latest version of react-native __Note__: This library is designed to work with the most recent version of react-native. If you aren't using the most recent version, you will probably need to download an older version of this library, as the API is likely to be different, and the dependencies are likely to break. From e4b98c6c4a69db64f1b7559d9bea2be8ed2b83a5 Mon Sep 17 00:00:00 2001 From: Jason Ma Date: Sat, 6 Jan 2018 12:40:32 -0800 Subject: [PATCH 20/20] Set base Node 8 test version to 8.9.1 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 3ae10f1..932b332 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ language: node_js node_js: - "6.0.0" - "6" - - "8.0.0" + - "8.9.1" - "8"