Fix JSTransformer/index test

Reviewed By: jeanlauliac

Differential Revision: D7019771

fbshipit-source-id: cbf232dc22f55d75dced3206b3c4ef1a472a7102
This commit is contained in:
Miguel Jimenez Esun 2018-02-19 04:57:24 -08:00 committed by Facebook Github Bot
parent dd48bb1fa3
commit 03c3b3d219
2 changed files with 13 additions and 3 deletions

View File

@ -34,6 +34,8 @@ describe('Transformer', function() {
}; };
beforeEach(function() { beforeEach(function() {
jest.resetModules();
Cache = jest.fn(); Cache = jest.fn();
Cache.prototype.get = jest.fn((a, b, c) => c()); Cache.prototype.get = jest.fn((a, b, c) => c());
@ -54,15 +56,23 @@ describe('Transformer', function() {
api[method] = jest.fn(); api[method] = jest.fn();
}); });
api.transform.mockImplementation(() => {
return {
result: 'transformed(code)',
transformFileStartLogEntry: {},
transformFileEndLogEntry: {},
};
});
return api; return api;
}); });
}); });
it('passes transform data to the worker farm when transforming', () => { it('passes transform data to the worker farm when transforming', async () => {
const transformOptions = {arbitrary: 'options'}; const transformOptions = {arbitrary: 'options'};
const code = 'arbitrary(code)'; const code = 'arbitrary(code)';
new Transformer(opts).transform( await new Transformer(opts).transform(
fileName, fileName,
localPath, localPath,
code, code,

View File

@ -99,7 +99,7 @@ module.exports = class Transformer {
assetRegistryPath: string, assetRegistryPath: string,
): Promise<TransformedCode> { ): Promise<TransformedCode> {
try { try {
debug('Started ransforming file', filename); debug('Started transforming file', filename);
const data = await this._worker.transform( const data = await this._worker.transform(
filename, filename,