Codemod tests to use top-level-requires

Reviewed By: @DmitrySoshnikov

Differential Revision: D2456250
This commit is contained in:
Christoph Pojer
2015-09-17 18:34:14 -07:00
committed by facebook-github-bot-5
parent 3fca7f4d7b
commit fa01b2e4cb
22 changed files with 162 additions and 220 deletions

View File

@@ -13,23 +13,19 @@ jest.setMock('worker-farm', function() { return () => {}; })
.mock('child_process')
.dontMock('../');
var SocketInterface = require('../');
var SocketClient = require('../SocketClient');
var childProcess = require('child_process');
var fs = require('fs');
describe('SocketInterface', () => {
let SocketInterface;
let SocketClient;
beforeEach(() => {
SocketInterface = require('../');
SocketClient = require('../SocketClient');
});
describe('getOrCreateSocketFor', () => {
pit('creates socket path by hashing options', () => {
const fs = require('fs');
fs.existsSync = jest.genMockFn().mockImpl(() => true);
fs.unlinkSync = jest.genMockFn();
let callback;
require('child_process').spawn.mockImpl(() => ({
childProcess.spawn.mockImpl(() => ({
on: (event, cb) => callback = cb,
send: (message) => {
setImmediate(() => callback({ type: 'createdServer' }));
@@ -58,13 +54,12 @@ describe('SocketInterface', () => {
});
pit('should fork a server', () => {
const fs = require('fs');
fs.existsSync = jest.genMockFn().mockImpl(() => false);
fs.unlinkSync = jest.genMockFn();
let sockPath;
let callback;
require('child_process').spawn.mockImpl(() => ({
childProcess.spawn.mockImpl(() => ({
on: (event, cb) => callback = cb,
send: (message) => {
expect(message.type).toBe('createSocketServer');