From e3f7a3933c1d975791267566c7de1cb539aa8301 Mon Sep 17 00:00:00 2001 From: Christoph Pojer Date: Mon, 21 Sep 2015 13:54:06 -0700 Subject: [PATCH] Fix tests + enable inline requires on react-native Reviewed By: @sahrens, @vjeux Differential Revision: D2456607 --- react-packager/src/Activity/__tests__/Activity-test.js | 6 +++--- react-packager/src/Cache/__tests__/Cache-test.js | 7 ++++--- .../src/FileWatcher/__tests__/FileWatcher-test.js | 8 ++++---- .../src/JSTransformer/__tests__/Transformer-test.js | 3 +-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/react-packager/src/Activity/__tests__/Activity-test.js b/react-packager/src/Activity/__tests__/Activity-test.js index ec0b8870..39d222ce 100644 --- a/react-packager/src/Activity/__tests__/Activity-test.js +++ b/react-packager/src/Activity/__tests__/Activity-test.js @@ -68,7 +68,7 @@ describe('Activity', () => { expect(() => { Activity.endEvent(eid); - }).toThrow('event(3) has already ended!'); + }).toThrow('event(1) has already ended!'); }); }); @@ -80,8 +80,8 @@ describe('Activity', () => { Activity.signal(EVENT_NAME, DATA); jest.runOnlyPendingTimers(); - expect(console.log.mock.calls.length).toBe(3); - const consoleMsg = console.log.mock.calls[2][0]; + expect(console.log.mock.calls.length).toBe(1); + const consoleMsg = console.log.mock.calls[0][0]; expect(consoleMsg).toContain(EVENT_NAME); expect(consoleMsg).toContain(JSON.stringify(DATA)); }); diff --git a/react-packager/src/Cache/__tests__/Cache-test.js b/react-packager/src/Cache/__tests__/Cache-test.js index 863a70b7..89c3196e 100644 --- a/react-packager/src/Cache/__tests__/Cache-test.js +++ b/react-packager/src/Cache/__tests__/Cache-test.js @@ -21,13 +21,14 @@ jest var Promise = require('promise'); var fs = require('fs'); +var os = require('os'); var _ = require('underscore'); +var Cache = require('../'); + describe('JSTransformer Cache', () => { - var Cache; beforeEach(() => { - require('os').tmpDir.mockImpl(() => 'tmpDir'); - Cache = require('../'); + os.tmpDir.mockImpl(() => 'tmpDir'); }); describe('getting/setting', () => { diff --git a/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js b/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js index 238da5b1..973c4f78 100644 --- a/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js +++ b/react-packager/src/FileWatcher/__tests__/FileWatcher-test.js @@ -19,14 +19,14 @@ jest } }); +var FileWatcher = require('../'); +var sane = require('sane'); + describe('FileWatcher', function() { - var FileWatcher; var Watcher; beforeEach(function() { - require('mock-modules').dumpCache(); - FileWatcher = require('../'); - Watcher = require('sane').WatchmanWatcher; + Watcher = sane.WatchmanWatcher; Watcher.prototype.once.mockImplementation(function(type, callback) { callback(); }); diff --git a/react-packager/src/JSTransformer/__tests__/Transformer-test.js b/react-packager/src/JSTransformer/__tests__/Transformer-test.js index 1ebf41cb..b182e1eb 100644 --- a/react-packager/src/JSTransformer/__tests__/Transformer-test.js +++ b/react-packager/src/JSTransformer/__tests__/Transformer-test.js @@ -15,12 +15,12 @@ jest jest.mock('fs'); var Cache = require('../../Cache'); +var Transformer = require('../'); var fs = require('fs'); var options; describe('Transformer', function() { - var Transformer; var workers; beforeEach(function() { @@ -33,7 +33,6 @@ describe('Transformer', function() { transformModulePath: '/foo/bar', cache: new Cache({}), }; - Transformer = require('../'); }); pit('should loadFileAndTransform', function() {