Remove `pit` and `mockImpl`

Reviewed By: dmitriiabramov

Differential Revision: D4321635

fbshipit-source-id: 460889a1f956f3733e7e49883dd97c9a8a561b86
This commit is contained in:
Christoph Pojer 2016-12-13 15:11:24 -08:00 committed by Facebook Github Bot
parent 4220063f84
commit 3e6d762ab7
7 changed files with 70 additions and 70 deletions

View File

@ -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,
@ -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({
@ -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,
@ -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'}),
@ -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(() => {
@ -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(() => {
@ -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({

View File

@ -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}');
});
@ -113,7 +113,7 @@ describe('Bundler', function() {
}),
];
getDependencies.mockImpl((main, options, transformOptions) =>
getDependencies.mockImplementation((main, options, transformOptions) =>
Promise.resolve({
mainModuleId: 'foo',
dependencies: modules,
@ -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: [
@ -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',
@ -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
@ -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],
@ -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',

View File

@ -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;
@ -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';

View File

@ -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;
}
@ -116,7 +116,7 @@ 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];
@ -124,7 +124,7 @@ describe('Resolver', function() {
projectRoot: '/root',
});
DependencyGraph.prototype.getDependencies.mockImpl(function() {
DependencyGraph.prototype.getDependencies.mockImplementation(function() {
return Promise.resolve(new ResolutionResponseMock({
dependencies: deps,
mainModuleId: 'index',
@ -237,7 +237,7 @@ describe('Resolver', function() {
});
});
pit('should get dependencies with polyfills', function() {
it('should get dependencies with polyfills', function() {
var module = createModule('index');
var deps = [module];
@ -245,7 +245,7 @@ describe('Resolver', function() {
projectRoot: '/root',
});
DependencyGraph.prototype.getDependencies.mockImpl(function() {
DependencyGraph.prototype.getDependencies.mockImplementation(function() {
return Promise.resolve(new ResolutionResponseMock({
dependencies: deps,
mainModuleId: 'index',
@ -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];
@ -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',
@ -325,7 +325,7 @@ describe('Resolver', function() {
});
});
pit('should resolve modules', function() {
it('should resolve modules', function() {
/*eslint-disable */
var code = [
// require
@ -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({
@ -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],
@ -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',
});
@ -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}) =>
@ -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)});`
@ -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}));

View File

@ -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();
@ -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();
@ -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();
@ -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();

View File

@ -29,8 +29,8 @@ describe('Cache', () => {
});
describe('getting/setting', () => {
pit('calls loader callback for uncached file', () => {
fs.stat.mockImpl((file, callback) => {
it('calls loader callback for uncached file', () => {
fs.stat.mockImplementation((file, callback) => {
callback(null, {
mtime: {
getTime: () => {},
@ -41,7 +41,7 @@ describe('Cache', () => {
var cache = new Cache({
cacheKey: 'cache',
});
var loaderCb = jest.genMockFn().mockImpl(() => Promise.resolve());
var loaderCb = jest.genMockFn().mockImplementation(() => Promise.resolve());
return cache
.get('/rootDir/someFile', 'field', loaderCb)
@ -50,8 +50,8 @@ describe('Cache', () => {
);
});
pit('supports storing multiple fields', () => {
fs.stat.mockImpl((file, callback) => {
it('supports storing multiple fields', () => {
fs.stat.mockImplementation((file, callback) => {
callback(null, {
mtime: {
getTime: () => {},
@ -63,7 +63,7 @@ describe('Cache', () => {
cacheKey: 'cache',
});
var index = 0;
var loaderCb = jest.genMockFn().mockImpl(() =>
var loaderCb = jest.genMockFn().mockImplementation(() =>
Promise.resolve(index++)
);
@ -77,8 +77,8 @@ describe('Cache', () => {
});
});
pit('gets the value from the loader callback', () => {
fs.stat.mockImpl((file, callback) =>
it('gets the value from the loader callback', () => {
fs.stat.mockImplementation((file, callback) =>
callback(null, {
mtime: {
getTime: () => {},
@ -89,7 +89,7 @@ describe('Cache', () => {
var cache = new Cache({
cacheKey: 'cache',
});
var loaderCb = jest.genMockFn().mockImpl(() =>
var loaderCb = jest.genMockFn().mockImplementation(() =>
Promise.resolve('lol')
);
@ -98,8 +98,8 @@ describe('Cache', () => {
.then(value => expect(value).toBe('lol'));
});
pit('caches the value after the first call', () => {
fs.stat.mockImpl((file, callback) => {
it('caches the value after the first call', () => {
fs.stat.mockImplementation((file, callback) => {
callback(null, {
mtime: {
getTime: () => {},
@ -110,7 +110,7 @@ describe('Cache', () => {
var cache = new Cache({
cacheKey: 'cache',
});
var loaderCb = jest.genMockFn().mockImpl(() =>
var loaderCb = jest.genMockFn().mockImplementation(() =>
Promise.resolve('lol')
);
@ -126,9 +126,9 @@ describe('Cache', () => {
});
});
pit('clears old field when getting new field and mtime changed', () => {
it('clears old field when getting new field and mtime changed', () => {
var mtime = 0;
fs.stat.mockImpl((file, callback) => {
fs.stat.mockImplementation((file, callback) => {
callback(null, {
mtime: {
getTime: () => mtime++,
@ -139,7 +139,7 @@ describe('Cache', () => {
var cache = new Cache({
cacheKey: 'cache',
});
var loaderCb = jest.genMockFn().mockImpl(() =>
var loaderCb = jest.genMockFn().mockImplementation(() =>
Promise.resolve('lol' + mtime)
);
@ -155,7 +155,7 @@ describe('Cache', () => {
});
it('does not cache rejections', () => {
fs.stat.mockImpl((file, callback) => {
fs.stat.mockImplementation((file, callback) => {
callback(null, {
mtime: {
getTime: () => {},
@ -196,11 +196,11 @@ describe('Cache', () => {
},
};
fs.existsSync.mockImpl(() => true);
fs.existsSync.mockImplementation(() => true);
fs.statSync.mockImpl(filePath => fileStats[filePath]);
fs.statSync.mockImplementation(filePath => fileStats[filePath]);
fs.readFileSync.mockImpl(() => JSON.stringify({
fs.readFileSync.mockImplementation(() => JSON.stringify({
'/rootDir/someFile': {
metadata: {mtime: 22},
data: {field: 'oh hai'},
@ -212,7 +212,7 @@ describe('Cache', () => {
}));
});
pit('should load cache from disk', () => {
it('should load cache from disk', () => {
var cache = new Cache({
cacheKey: 'cache',
});
@ -233,8 +233,8 @@ describe('Cache', () => {
});
});
pit('should not load outdated cache', () => {
fs.stat.mockImpl((file, callback) =>
it('should not load outdated cache', () => {
fs.stat.mockImplementation((file, callback) =>
callback(null, {
mtime: {
getTime: () => {},
@ -247,7 +247,7 @@ describe('Cache', () => {
var cache = new Cache({
cacheKey: 'cache',
});
var loaderCb = jest.genMockFn().mockImpl(() =>
var loaderCb = jest.genMockFn().mockImplementation(() =>
Promise.resolve('new value')
);
@ -272,7 +272,7 @@ describe('Cache', () => {
var index = 0;
var mtimes = [10, 20, 30];
fs.stat.mockImpl((file, callback) =>
fs.stat.mockImplementation((file, callback) =>
callback(null, {
mtime: {
getTime: () => mtimes[index++],
@ -303,7 +303,7 @@ describe('Cache', () => {
describe('check for cache presence', () => {
it('synchronously resolves cache presence', () => {
fs.stat.mockImpl((file, callback) =>
fs.stat.mockImplementation((file, callback) =>
callback(null, {
mtime: {
getTime: () => {},
@ -314,7 +314,7 @@ describe('Cache', () => {
var cache = new Cache({
cacheKey: 'cache',
});
var loaderCb = jest.genMockFn().mockImpl(() =>
var loaderCb = jest.genMockFn().mockImplementation(() =>
Promise.resolve('banana')
);
var file = '/rootDir/someFile';
@ -331,7 +331,7 @@ describe('Cache', () => {
describe('invalidate', () => {
it('invalidates the cache per file or per-field', () => {
fs.stat.mockImpl((file, callback) =>
fs.stat.mockImplementation((file, callback) =>
callback(null, {
mtime: {
getTime: () => {},
@ -342,7 +342,7 @@ describe('Cache', () => {
var cache = new Cache({
cacheKey: 'cache',
});
var loaderCb = jest.genMockFn().mockImpl(() =>
var loaderCb = jest.genMockFn().mockImplementation(() =>
Promise.resolve('banana')
);
var file = '/rootDir/someFile';

View File

@ -15,12 +15,12 @@ const AssetModule = require('../AssetModule');
describe('AssetModule:', () => {
const defaults = {file: '/arbitrary'};
pit('has no dependencies by default', () => {
it('has no dependencies by default', () => {
return new AssetModule(defaults).getDependencies()
.then(deps => expect(deps).toEqual([]));
});
pit('can be parametrized with dependencies', () => {
it('can be parametrized with dependencies', () => {
const dependencies = ['arbitrary', 'dependencies'];
return new AssetModule({...defaults, dependencies}).getDependencies()
.then(deps => expect(deps).toEqual(dependencies));