Skip to content

Commit

Permalink
Remove pit and mockImpl
Browse files Browse the repository at this point in the history
Reviewed By: dmitriiabramov

Differential Revision: D4321635

fbshipit-source-id: 460889a1f956f3733e7e49883dd97c9a8a561b86
  • Loading branch information
cpojer authored and Facebook Github Bot committed Dec 13, 2016
1 parent 4220063 commit 3e6d762
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 70 deletions.
14 changes: 7 additions & 7 deletions packager/react-packager/src/Bundler/__tests__/Bundle-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ describe('Bundle', () => {
});

describe('source bundle', () => {
pit('should create a bundle and get the source', () => {
it('should create a bundle and get the source', () => {
return Promise.resolve().then(() => {
return addModule({
bundle,
Expand All @@ -51,7 +51,7 @@ describe('Bundle', () => {
});
});

pit('should be ok to leave out the source map url', () => {
it('should be ok to leave out the source map url', () => {
const otherBundle = new Bundle();
return Promise.resolve().then(() => {
return addModule({
Expand All @@ -76,7 +76,7 @@ describe('Bundle', () => {
});
});

pit('should create a bundle and add run module code', () => {
it('should create a bundle and add run module code', () => {
return Promise.resolve().then(() => {
return addModule({
bundle,
Expand Down Expand Up @@ -107,7 +107,7 @@ describe('Bundle', () => {
});
});

pit('should insert modules in a deterministic order, independent from timing of the wrapping process', () => {
it('should insert modules in a deterministic order, independent from timing of the wrapping process', () => {
const moduleTransports = [
createModuleTransport({name: 'module1'}),
createModuleTransport({name: 'module2'}),
Expand Down Expand Up @@ -137,7 +137,7 @@ describe('Bundle', () => {
});

describe('sourcemap bundle', () => {
pit('should create sourcemap', () => {
it('should create sourcemap', () => {
const otherBundle = new Bundle({sourceMapUrl: 'test_url'});

return Promise.resolve().then(() => {
Expand Down Expand Up @@ -181,7 +181,7 @@ describe('Bundle', () => {
});
});

pit('should combine sourcemaps', () => {
it('should combine sourcemaps', () => {
const otherBundle = new Bundle({sourceMapUrl: 'test_url'});

return Promise.resolve().then(() => {
Expand Down Expand Up @@ -283,7 +283,7 @@ describe('Bundle', () => {
});

describe('getJSModulePaths()', () => {
pit('should return module paths', () => {
it('should return module paths', () => {
var otherBundle = new Bundle({sourceMapUrl: 'test_url'});
return Promise.resolve().then(() => {
return addModule({
Expand Down
22 changes: 11 additions & 11 deletions packager/react-packager/src/Bundler/__tests__/Bundler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,20 @@ describe('Bundler', function() {
getModuleSystemDependencies = jest.fn();
projectRoots = ['/root'];

Resolver.mockImpl(function() {
Resolver.mockImplementation(function() {
return {
getDependencies: getDependencies,
getModuleSystemDependencies: getModuleSystemDependencies,
};
});

fs.statSync.mockImpl(function() {
fs.statSync.mockImplementation(function() {
return {
isDirectory: () => true
};
});

fs.readFile.mockImpl(function(file, callback) {
fs.readFile.mockImplementation(function(file, callback) {
callback(null, '{"json":true}');
});

Expand Down Expand Up @@ -113,7 +113,7 @@ describe('Bundler', function() {
}),
];

getDependencies.mockImpl((main, options, transformOptions) =>
getDependencies.mockImplementation((main, options, transformOptions) =>
Promise.resolve({
mainModuleId: 'foo',
dependencies: modules,
Expand All @@ -123,17 +123,17 @@ describe('Bundler', function() {
})
);

getModuleSystemDependencies.mockImpl(function() {
getModuleSystemDependencies.mockImplementation(function() {
return [];
});

sizeOf.mockImpl(function(path, cb) {
sizeOf.mockImplementation(function(path, cb) {
cb(null, { width: 50, height: 100 });
});
});

it('create a bundle', function() {
assetServer.getAssetData.mockImpl(() => {
assetServer.getAssetData.mockImplementation(() => {
return {
scales: [1,2,3],
files: [
Expand Down Expand Up @@ -217,7 +217,7 @@ describe('Bundler', function() {
name: 'img',
type: 'png',
};
assetServer.getAssetData.mockImpl(() => mockAsset);
assetServer.getAssetData.mockImplementation(() => mockAsset);

return bundler.bundle({
entryFile: '/root/foo.js',
Expand Down Expand Up @@ -247,7 +247,7 @@ describe('Bundler', function() {
});
});

pit('gets the list of dependencies from the resolver', function() {
it('gets the list of dependencies from the resolver', function() {
const entryFile = '/root/foo.js';
return bundler.getDependencies({entryFile, recursive: true}).then(() =>
// jest calledWith does not support jasmine.any
Expand Down Expand Up @@ -279,7 +279,7 @@ describe('Bundler', function() {

describe('getOrderedDependencyPaths', () => {
beforeEach(() => {
assetServer.getAssetData.mockImpl(function(relPath) {
assetServer.getAssetData.mockImplementation(function(relPath) {
if (relPath === 'img/new_image.png') {
return {
scales: [1,2,3],
Expand Down Expand Up @@ -310,7 +310,7 @@ describe('Bundler', function() {
});
});

pit('should get the concrete list of all dependency files', () => {
it('should get the concrete list of all dependency files', () => {
modules.push(
createModule({
id: 'new_image2.png',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ describe('Transformer', function() {
fs.writeFileSync.mockClear();
options = {transformModulePath};
workerFarm.mockClear();
workerFarm.mockImpl((opts, path, methods) => {
workerFarm.mockImplementation((opts, path, methods) => {
const api = workers = {};
methods.forEach(method => {api[method] = jest.fn();});
return api;
Expand All @@ -57,12 +57,12 @@ describe('Transformer', function() {
);
});

pit('should add file info to parse errors', function() {
it('should add file info to parse errors', function() {
const transformer = new Transformer(options);
var message = 'message';
var snippet = 'snippet';

workers.transformAndExtractDependencies.mockImpl(
workers.transformAndExtractDependencies.mockImplementation(
function(transformPath, filename, code, opts, callback) {
var babelError = new SyntaxError(message);
babelError.type = 'SyntaxError';
Expand Down
30 changes: 15 additions & 15 deletions packager/react-packager/src/Resolver/__tests__/Resolver-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ describe('Resolver', function() {
function createModule(id, dependencies) {
var module = new Module({});
module.path = id;
module.getName.mockImpl(() => Promise.resolve(id));
module.getDependencies.mockImpl(() => Promise.resolve(dependencies));
module.getName.mockImplementation(() => Promise.resolve(id));
module.getDependencies.mockImplementation(() => Promise.resolve(dependencies));
return module;
}

Expand Down Expand Up @@ -116,15 +116,15 @@ describe('Resolver', function() {
expect(platforms).toEqual(['ios', 'windows', 'vr']);
});

pit('should get dependencies with polyfills', function() {
it('should get dependencies with polyfills', function() {
var module = createModule('index');
var deps = [module];

var depResolver = new Resolver({
projectRoot: '/root',
});

DependencyGraph.prototype.getDependencies.mockImpl(function() {
DependencyGraph.prototype.getDependencies.mockImplementation(function() {
return Promise.resolve(new ResolutionResponseMock({
dependencies: deps,
mainModuleId: 'index',
Expand Down Expand Up @@ -237,15 +237,15 @@ describe('Resolver', function() {
});
});

pit('should get dependencies with polyfills', function() {
it('should get dependencies with polyfills', function() {
var module = createModule('index');
var deps = [module];

var depResolver = new Resolver({
projectRoot: '/root',
});

DependencyGraph.prototype.getDependencies.mockImpl(function() {
DependencyGraph.prototype.getDependencies.mockImplementation(function() {
return Promise.resolve(new ResolutionResponseMock({
dependencies: deps,
mainModuleId: 'index',
Expand All @@ -271,7 +271,7 @@ describe('Resolver', function() {
});
});

pit('should pass in more polyfills', function() {
it('should pass in more polyfills', function() {
var module = createModule('index');
var deps = [module];

Expand All @@ -280,7 +280,7 @@ describe('Resolver', function() {
polyfillModuleNames: ['some module'],
});

DependencyGraph.prototype.getDependencies.mockImpl(function() {
DependencyGraph.prototype.getDependencies.mockImplementation(function() {
return Promise.resolve(new ResolutionResponseMock({
dependencies: deps,
mainModuleId: 'index',
Expand Down Expand Up @@ -325,7 +325,7 @@ describe('Resolver', function() {
});
});

pit('should resolve modules', function() {
it('should resolve modules', function() {
/*eslint-disable */
var code = [
// require
Expand Down Expand Up @@ -387,7 +387,7 @@ describe('Resolver', function() {
});
});

pit('should add module transport names as fourth argument to `__d`', () => {
it('should add module transport names as fourth argument to `__d`', () => {
const module = createModule('test module');
const code = 'arbitrary(code)'
const resolutionResponse = new ResolutionResponseMock({
Expand All @@ -409,7 +409,7 @@ describe('Resolver', function() {
);
});

pit('should pass through passed-in source maps', () => {
it('should pass through passed-in source maps', () => {
const module = createModule('test module');
const resolutionResponse = new ResolutionResponseMock({
dependencies: [module],
Expand All @@ -425,7 +425,7 @@ describe('Resolver', function() {
}).then(({map}) => expect(map).toBe(inputMap));
});

pit('should resolve polyfills', function () {
it('should resolve polyfills', function () {
const depResolver = new Resolver({
projectRoot: '/root',
});
Expand Down Expand Up @@ -459,7 +459,7 @@ describe('Resolver', function() {
});
});

pit('should prefix JSON files with `module.exports=`', () => {
it('should prefix JSON files with `module.exports=`', () => {
return depResolver
.wrapModule({resolutionResponse, module, name: id, code, dev: false})
.then(({code: processedCode}) =>
Expand Down Expand Up @@ -491,7 +491,7 @@ describe('Resolver', function() {
sourceMap = {version: 3, sources: ['input'], mappings: 'whatever'};
});

pit('should invoke the minifier with the wrapped code', () => {
it('should invoke the minifier with the wrapped code', () => {
const wrappedCode =
`__d(/* ${id} */function(global, require, module, exports) {${
code}\n}, ${resolutionResponse.getModuleId(module)});`
Expand All @@ -509,7 +509,7 @@ describe('Resolver', function() {
});
});

pit('should use minified code', () => {
it('should use minified code', () => {
const minifiedCode = 'minified(code)';
const minifiedMap = {version: 3, file: ['minified']};
minifyCode.mockReturnValue(Promise.resolve({code: minifiedCode, map: minifiedMap}));
Expand Down
8 changes: 4 additions & 4 deletions packager/react-packager/src/Server/__tests__/Server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ describe('processRequest', () => {
const req = {url: '/assets/imgs/a.png'};
const res = {end: jest.fn(), setHeader: jest.fn()};

AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
AssetServer.prototype.get.mockImplementation(() => Promise.resolve('i am image'));

server.processRequest(req, res);
jest.runAllTimers();
Expand All @@ -362,7 +362,7 @@ describe('processRequest', () => {
const req = {url: '/assets/imgs/a.png?platform=ios'};
const res = {end: jest.fn(), setHeader: jest.fn()};

AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
AssetServer.prototype.get.mockImplementation(() => Promise.resolve('i am image'));

server.processRequest(req, res);
jest.runAllTimers();
Expand All @@ -375,7 +375,7 @@ describe('processRequest', () => {
const res = {end: jest.fn(), writeHead: jest.fn(), setHeader: jest.fn()};
const mockData = 'i am image';

AssetServer.prototype.get.mockImpl(() => Promise.resolve(mockData));
AssetServer.prototype.get.mockImplementation(() => Promise.resolve(mockData));

server.processRequest(req, res);
jest.runAllTimers();
Expand All @@ -387,7 +387,7 @@ describe('processRequest', () => {
const req = {url: '/assets/imgs/%E4%B8%BB%E9%A1%B5/logo.png'};
const res = {end: jest.fn(), setHeader: jest.fn()};

AssetServer.prototype.get.mockImpl(() => Promise.resolve('i am image'));
AssetServer.prototype.get.mockImplementation(() => Promise.resolve('i am image'));

server.processRequest(req, res);
jest.runAllTimers();
Expand Down
Loading

0 comments on commit 3e6d762

Please sign in to comment.