From 3360999431b4ed931068ac2f96c8234cdd1f6662 Mon Sep 17 00:00:00 2001 From: James Burnett Date: Thu, 8 Jun 2017 07:36:21 -0700 Subject: [PATCH] disable automock by default in as many places as possible @bypass-lint Reviewed By: cpojer Differential Revision: D5190858 fbshipit-source-id: d3125cf81427dbbe3362ef1f958413394a6dc51d --- Libraries/Animated/src/__tests__/Easing-test.js | 2 +- Libraries/Animated/src/__tests__/Interpolation-test.js | 5 +---- Libraries/Animated/src/__tests__/bezier-test.js | 2 +- Libraries/BatchedBridge/__tests__/MessageQueue-test.js | 3 +-- .../BatchedBridge/__tests__/NativeModules-test.js | 10 ++++++---- Libraries/Image/__tests__/resolveAssetSource-test.js | 6 +----- .../Interaction/__tests__/InteractionMixin-test.js | 2 +- Libraries/Interaction/__tests__/TaskQueue-test.js | 2 +- Libraries/Lists/__tests__/FillRateHelper-test.js | 2 +- Libraries/Lists/__tests__/ViewabilityHelper-test.js | 2 +- Libraries/Lists/__tests__/VirtualizeUtils-test.js | 2 +- Libraries/Network/__tests__/FormData-test.js | 2 +- Libraries/StyleSheet/__tests__/normalizeColor-test.js | 2 +- .../__tests__/setNormalizedColorAlpha-test.js | 3 +-- Libraries/Utilities/__tests__/MatrixMath-test.js | 3 +-- Libraries/Utilities/__tests__/Platform-test.js | 3 +-- Libraries/Utilities/__tests__/SceneTracker-test.js | 2 +- .../Utilities/__tests__/buildStyleInterpolator-test.js | 2 +- .../deepFreezeAndThrowOnMutationInDev-test.js | 2 +- Libraries/Utilities/__tests__/groupByEveryN-test.js | 2 +- Libraries/Utilities/__tests__/mapWithSeparator-test.js | 2 +- Libraries/Utilities/__tests__/truncate-test.js | 2 +- .../Utilities/differ/__tests__/deepDiffer-test.js | 2 +- Libraries/WebSocket/__tests__/WebSocket-test.js | 2 +- .../bundle/__tests__/filterPlatformAssetScales-test.js | 2 +- .../bundle/__tests__/getAssetDestPathAndroid-test.js | 2 +- local-cli/bundle/__tests__/getAssetDestPathIOS-test.js | 2 +- local-cli/core/__tests__/makeCommand.spec.js | 1 + .../runIOS/__tests__/findMatchingSimulator-test.js | 2 +- local-cli/runIOS/__tests__/findXcodeProject-test.js | 2 +- local-cli/runIOS/__tests__/parseIOSDevicesList-test.js | 2 +- .../util/__tests__/getInverseDependencies-test.js | 2 +- .../templates/HelloWorld/__tests__/index.android.js | 1 + local-cli/templates/HelloWorld/__tests__/index.ios.js | 1 + 34 files changed, 39 insertions(+), 45 deletions(-) diff --git a/Libraries/Animated/src/__tests__/Easing-test.js b/Libraries/Animated/src/__tests__/Easing-test.js index 164709085..885c9dd17 100644 --- a/Libraries/Animated/src/__tests__/Easing-test.js +++ b/Libraries/Animated/src/__tests__/Easing-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest.unmock('Easing'); +jest.disableAutomock(); var Easing = require('Easing'); describe('Easing', () => { diff --git a/Libraries/Animated/src/__tests__/Interpolation-test.js b/Libraries/Animated/src/__tests__/Interpolation-test.js index 54d3ee460..3f0fb8371 100644 --- a/Libraries/Animated/src/__tests__/Interpolation-test.js +++ b/Libraries/Animated/src/__tests__/Interpolation-test.js @@ -8,10 +8,7 @@ */ 'use strict'; -jest - .unmock('Interpolation') - .unmock('Easing') - .unmock('normalizeColor'); +jest.disableAutomock(); var Interpolation = require('Interpolation'); var Easing = require('Easing'); diff --git a/Libraries/Animated/src/__tests__/bezier-test.js b/Libraries/Animated/src/__tests__/bezier-test.js index 4e3c8a9ce..202494ed8 100644 --- a/Libraries/Animated/src/__tests__/bezier-test.js +++ b/Libraries/Animated/src/__tests__/bezier-test.js @@ -10,7 +10,7 @@ 'use strict'; -jest.unmock('bezier'); +jest.disableAutomock(); var bezier = require('bezier'); var identity = function (x) { return x; }; diff --git a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js index c5f69840d..1da3557ca 100644 --- a/Libraries/BatchedBridge/__tests__/MessageQueue-test.js +++ b/Libraries/BatchedBridge/__tests__/MessageQueue-test.js @@ -10,8 +10,7 @@ 'use strict'; // const MessageQueueTestConfig = require('MessageQueueTestConfig'); -jest.unmock('MessageQueue'); -jest.unmock('defineLazyObjectProperty'); +jest.disableAutomock(); let MessageQueue; let MessageQueueTestModule; diff --git a/Libraries/BatchedBridge/__tests__/NativeModules-test.js b/Libraries/BatchedBridge/__tests__/NativeModules-test.js index fb0959243..9385830ef 100644 --- a/Libraries/BatchedBridge/__tests__/NativeModules-test.js +++ b/Libraries/BatchedBridge/__tests__/NativeModules-test.js @@ -9,10 +9,12 @@ */ 'use strict'; -jest.unmock('BatchedBridge'); -jest.unmock('defineLazyObjectProperty'); -jest.unmock('MessageQueue'); -jest.unmock('NativeModules'); +jest + .enableAutomock() + .unmock('BatchedBridge') + .unmock('defineLazyObjectProperty') + .unmock('MessageQueue') + .unmock('NativeModules'); let BatchedBridge; let NativeModules; diff --git a/Libraries/Image/__tests__/resolveAssetSource-test.js b/Libraries/Image/__tests__/resolveAssetSource-test.js index 091cf832b..77ef3a284 100644 --- a/Libraries/Image/__tests__/resolveAssetSource-test.js +++ b/Libraries/Image/__tests__/resolveAssetSource-test.js @@ -8,11 +8,7 @@ */ 'use strict'; -jest - .unmock('AssetRegistry') - .unmock('AssetSourceResolver') - .unmock('../resolveAssetSource') - .unmock('../../../local-cli/bundle/assetPathUtils'); +jest.disableAutomock(); var AssetRegistry = require('AssetRegistry'); var Platform = require('Platform'); diff --git a/Libraries/Interaction/__tests__/InteractionMixin-test.js b/Libraries/Interaction/__tests__/InteractionMixin-test.js index 2e379e466..3e41ff652 100644 --- a/Libraries/Interaction/__tests__/InteractionMixin-test.js +++ b/Libraries/Interaction/__tests__/InteractionMixin-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('InteractionMixin'); +jest.enableAutomock().unmock('InteractionMixin'); describe('InteractionMixin', () => { var InteractionManager; diff --git a/Libraries/Interaction/__tests__/TaskQueue-test.js b/Libraries/Interaction/__tests__/TaskQueue-test.js index 004e10e09..7b4d98fd0 100644 --- a/Libraries/Interaction/__tests__/TaskQueue-test.js +++ b/Libraries/Interaction/__tests__/TaskQueue-test.js @@ -10,7 +10,7 @@ 'use strict'; -jest.unmock('TaskQueue'); +jest.disableAutomock(); function expectToBeCalledOnce(fn) { expect(fn.mock.calls.length).toBe(1); diff --git a/Libraries/Lists/__tests__/FillRateHelper-test.js b/Libraries/Lists/__tests__/FillRateHelper-test.js index 4d4a21f9a..15b41e81d 100644 --- a/Libraries/Lists/__tests__/FillRateHelper-test.js +++ b/Libraries/Lists/__tests__/FillRateHelper-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('FillRateHelper'); +jest.disableAutomock(); const FillRateHelper = require('FillRateHelper'); diff --git a/Libraries/Lists/__tests__/ViewabilityHelper-test.js b/Libraries/Lists/__tests__/ViewabilityHelper-test.js index 25d98fc38..a89903889 100644 --- a/Libraries/Lists/__tests__/ViewabilityHelper-test.js +++ b/Libraries/Lists/__tests__/ViewabilityHelper-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('ViewabilityHelper'); +jest.disableAutomock(); const ViewabilityHelper = require('ViewabilityHelper'); diff --git a/Libraries/Lists/__tests__/VirtualizeUtils-test.js b/Libraries/Lists/__tests__/VirtualizeUtils-test.js index 5dc748738..0b6c6b6e0 100644 --- a/Libraries/Lists/__tests__/VirtualizeUtils-test.js +++ b/Libraries/Lists/__tests__/VirtualizeUtils-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('VirtualizeUtils'); +jest.disableAutomock(); const { elementsThatOverlapOffsets, newRangeCount } = require('VirtualizeUtils'); diff --git a/Libraries/Network/__tests__/FormData-test.js b/Libraries/Network/__tests__/FormData-test.js index f2f4f33e8..b50612962 100644 --- a/Libraries/Network/__tests__/FormData-test.js +++ b/Libraries/Network/__tests__/FormData-test.js @@ -9,7 +9,7 @@ 'use strict'; -jest.unmock('FormData'); +jest.disableAutomock(); const FormData = require('FormData'); diff --git a/Libraries/StyleSheet/__tests__/normalizeColor-test.js b/Libraries/StyleSheet/__tests__/normalizeColor-test.js index 4090e5108..8db615a44 100644 --- a/Libraries/StyleSheet/__tests__/normalizeColor-test.js +++ b/Libraries/StyleSheet/__tests__/normalizeColor-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest.unmock('normalizeColor'); +jest.disableAutomock(); var normalizeColor = require('normalizeColor'); diff --git a/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js b/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js index 6a29df07a..c8d90b71e 100644 --- a/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js +++ b/Libraries/StyleSheet/__tests__/setNormalizedColorAlpha-test.js @@ -8,8 +8,7 @@ */ 'use strict'; -jest.unmock('setNormalizedColorAlpha'); -jest.unmock('normalizeColor'); +jest.disableAutomock(); var setNormalizedColorAlpha = require('setNormalizedColorAlpha'); var normalizeColor = require('normalizeColor'); diff --git a/Libraries/Utilities/__tests__/MatrixMath-test.js b/Libraries/Utilities/__tests__/MatrixMath-test.js index 949509c54..14cca94de 100644 --- a/Libraries/Utilities/__tests__/MatrixMath-test.js +++ b/Libraries/Utilities/__tests__/MatrixMath-test.js @@ -8,8 +8,7 @@ */ 'use strict'; -jest.unmock('MatrixMath'); -jest.unmock('fbjs/lib/invariant'); +jest.disableAutomock(); var MatrixMath = require('MatrixMath'); diff --git a/Libraries/Utilities/__tests__/Platform-test.js b/Libraries/Utilities/__tests__/Platform-test.js index 625ca3f03..ffa3a1b08 100644 --- a/Libraries/Utilities/__tests__/Platform-test.js +++ b/Libraries/Utilities/__tests__/Platform-test.js @@ -8,8 +8,7 @@ */ 'use strict'; -jest.unmock('../Platform.ios'); -jest.unmock('../Platform.android'); +jest.disableAutomock(); var PlatformIOS = require('../Platform.ios'); var PlatformAndroid = require('../Platform.android'); diff --git a/Libraries/Utilities/__tests__/SceneTracker-test.js b/Libraries/Utilities/__tests__/SceneTracker-test.js index c27a1b366..73e384adb 100644 --- a/Libraries/Utilities/__tests__/SceneTracker-test.js +++ b/Libraries/Utilities/__tests__/SceneTracker-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('SceneTracker'); +jest.disableAutomock(); const SceneTracker = require('SceneTracker'); diff --git a/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js b/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js index 4cb1b29fd..add38b327 100644 --- a/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js +++ b/Libraries/Utilities/__tests__/buildStyleInterpolator-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('buildStyleInterpolator'); +jest.disableAutomock(); var buildStyleInterpolator = require('buildStyleInterpolator'); diff --git a/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js b/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js index 4db4e749e..2d35d656f 100644 --- a/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js +++ b/Libraries/Utilities/__tests__/deepFreezeAndThrowOnMutationInDev-test.js @@ -7,7 +7,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * */ -jest.unmock('deepFreezeAndThrowOnMutationInDev'); +jest.disableAutomock(); var deepFreezeAndThrowOnMutationInDev = require('deepFreezeAndThrowOnMutationInDev'); describe('deepFreezeAndThrowOnMutationInDev', function() { diff --git a/Libraries/Utilities/__tests__/groupByEveryN-test.js b/Libraries/Utilities/__tests__/groupByEveryN-test.js index 0777716c4..4fb93a38c 100644 --- a/Libraries/Utilities/__tests__/groupByEveryN-test.js +++ b/Libraries/Utilities/__tests__/groupByEveryN-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('groupByEveryN'); +jest.disableAutomock(); describe('groupByEveryN', () => { var groupByEveryN = require('groupByEveryN'); diff --git a/Libraries/Utilities/__tests__/mapWithSeparator-test.js b/Libraries/Utilities/__tests__/mapWithSeparator-test.js index 4dea1ec7b..54fc5e832 100644 --- a/Libraries/Utilities/__tests__/mapWithSeparator-test.js +++ b/Libraries/Utilities/__tests__/mapWithSeparator-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest.unmock('mapWithSeparator'); +jest.disableAutomock(); describe('mapWithSeparator', () => { const mapWithSeparator = require('mapWithSeparator'); diff --git a/Libraries/Utilities/__tests__/truncate-test.js b/Libraries/Utilities/__tests__/truncate-test.js index 3404688c8..9cf3de653 100644 --- a/Libraries/Utilities/__tests__/truncate-test.js +++ b/Libraries/Utilities/__tests__/truncate-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.unmock('truncate'); +jest.disableAutomock(); describe('truncate', () => { diff --git a/Libraries/Utilities/differ/__tests__/deepDiffer-test.js b/Libraries/Utilities/differ/__tests__/deepDiffer-test.js index c1cc81c88..847efc212 100644 --- a/Libraries/Utilities/differ/__tests__/deepDiffer-test.js +++ b/Libraries/Utilities/differ/__tests__/deepDiffer-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest.unmock('deepDiffer'); +jest.disableAutomock(); var deepDiffer = require('deepDiffer'); describe('deepDiffer', function() { diff --git a/Libraries/WebSocket/__tests__/WebSocket-test.js b/Libraries/WebSocket/__tests__/WebSocket-test.js index cb9b15415..83a6b5ab2 100644 --- a/Libraries/WebSocket/__tests__/WebSocket-test.js +++ b/Libraries/WebSocket/__tests__/WebSocket-test.js @@ -3,7 +3,7 @@ */ 'use strict'; -jest.unmock('WebSocket'); +jest.enableAutomock().unmock('WebSocket'); jest.setMock('NativeModules', { WebSocketModule: { connect: () => {} diff --git a/local-cli/bundle/__tests__/filterPlatformAssetScales-test.js b/local-cli/bundle/__tests__/filterPlatformAssetScales-test.js index 1db781c23..092046020 100644 --- a/local-cli/bundle/__tests__/filterPlatformAssetScales-test.js +++ b/local-cli/bundle/__tests__/filterPlatformAssetScales-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest +jest.disableAutomock() .dontMock('../filterPlatformAssetScales') .dontMock('../assetPathUtils'); diff --git a/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js b/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js index 3f5829954..b0ffaa194 100644 --- a/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js +++ b/local-cli/bundle/__tests__/getAssetDestPathAndroid-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest +jest.disableAutomock() .dontMock('../getAssetDestPathAndroid') .dontMock('../assetPathUtils'); diff --git a/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js b/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js index d30441b48..fdfd6ae96 100644 --- a/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js +++ b/local-cli/bundle/__tests__/getAssetDestPathIOS-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest.dontMock('../getAssetDestPathIOS'); +jest.disableAutomock().dontMock('../getAssetDestPathIOS'); const getAssetDestPathIOS = require('../getAssetDestPathIOS'); diff --git a/local-cli/core/__tests__/makeCommand.spec.js b/local-cli/core/__tests__/makeCommand.spec.js index b0f643fb9..dfd05ccc6 100644 --- a/local-cli/core/__tests__/makeCommand.spec.js +++ b/local-cli/core/__tests__/makeCommand.spec.js @@ -1,3 +1,4 @@ +jest.disableAutomock(); var spawnError = false; jest.setMock('child_process', { diff --git a/local-cli/runIOS/__tests__/findMatchingSimulator-test.js b/local-cli/runIOS/__tests__/findMatchingSimulator-test.js index 957f80cf6..31fa4dbbd 100644 --- a/local-cli/runIOS/__tests__/findMatchingSimulator-test.js +++ b/local-cli/runIOS/__tests__/findMatchingSimulator-test.js @@ -9,7 +9,7 @@ */ 'use strict'; -jest.dontMock('../findMatchingSimulator'); +jest.disableAutomock().dontMock('../findMatchingSimulator'); const findMatchingSimulator = require('../findMatchingSimulator'); diff --git a/local-cli/runIOS/__tests__/findXcodeProject-test.js b/local-cli/runIOS/__tests__/findXcodeProject-test.js index d0e3832be..295386a0d 100644 --- a/local-cli/runIOS/__tests__/findXcodeProject-test.js +++ b/local-cli/runIOS/__tests__/findXcodeProject-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest.dontMock('../findXcodeProject'); +jest.disableAutomock().dontMock('../findXcodeProject'); const findXcodeProject = require('../findXcodeProject'); diff --git a/local-cli/runIOS/__tests__/parseIOSDevicesList-test.js b/local-cli/runIOS/__tests__/parseIOSDevicesList-test.js index 82071cd3d..4f3540367 100644 --- a/local-cli/runIOS/__tests__/parseIOSDevicesList-test.js +++ b/local-cli/runIOS/__tests__/parseIOSDevicesList-test.js @@ -9,7 +9,7 @@ 'use strict'; -jest.dontMock('../parseIOSDevicesList'); +jest.disableAutomock().dontMock('../parseIOSDevicesList'); var parseIOSDevicesList = require('../parseIOSDevicesList'); describe('parseIOSDevicesList', () => { diff --git a/local-cli/server/util/__tests__/getInverseDependencies-test.js b/local-cli/server/util/__tests__/getInverseDependencies-test.js index dafaa9e16..061e35e6e 100644 --- a/local-cli/server/util/__tests__/getInverseDependencies-test.js +++ b/local-cli/server/util/__tests__/getInverseDependencies-test.js @@ -8,7 +8,7 @@ */ 'use strict'; -jest.dontMock('../getInverseDependencies'); +jest.disableAutomock().dontMock('../getInverseDependencies'); const getInverseDependencies = require('../getInverseDependencies'); diff --git a/local-cli/templates/HelloWorld/__tests__/index.android.js b/local-cli/templates/HelloWorld/__tests__/index.android.js index b49b9087f..d5fd11aa0 100644 --- a/local-cli/templates/HelloWorld/__tests__/index.android.js +++ b/local-cli/templates/HelloWorld/__tests__/index.android.js @@ -1,3 +1,4 @@ +jest.disableAutomock(); import 'react-native'; import React from 'react'; import Index from '../index.android.js'; diff --git a/local-cli/templates/HelloWorld/__tests__/index.ios.js b/local-cli/templates/HelloWorld/__tests__/index.ios.js index ba7c5b5e1..4d2e20757 100644 --- a/local-cli/templates/HelloWorld/__tests__/index.ios.js +++ b/local-cli/templates/HelloWorld/__tests__/index.ios.js @@ -1,3 +1,4 @@ +jest.disableAutomock(); import 'react-native'; import React from 'react'; import Index from '../index.ios.js';