mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-06 00:43:38 +08:00
Codemod tests to use top-level-requires
Reviewed By: @DmitrySoshnikov Differential Revision: D2456250
This commit is contained in:
committed by
facebook-github-bot-5
parent
3fca7f4d7b
commit
fa01b2e4cb
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user