Add @format to a few files

Reviewed By: davidaurelio

Differential Revision: D5111297

fbshipit-source-id: bde11df412dd694edca78d6a61f4c69e5abba60a
This commit is contained in:
Christoph Pojer 2017-05-23 04:52:46 -07:00 committed by Facebook Github Bot
parent 0eccb5ebf4
commit f8a724121b
5 changed files with 3343 additions and 3011 deletions

View File

@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/ */
'use strict'; 'use strict';
@ -26,88 +28,99 @@ describe('Bundle', () => {
describe('source bundle', () => { describe('source bundle', () => {
it('should create a bundle and get the source', () => { it('should create a bundle and get the source', () => {
return Promise.resolve().then(() => { return Promise.resolve()
.then(() => {
return addModule({ return addModule({
bundle, bundle,
code: 'transformed foo;', code: 'transformed foo;',
sourceCode: 'source foo', sourceCode: 'source foo',
sourcePath: 'foo path', sourcePath: 'foo path',
}); });
}).then(() => { })
.then(() => {
return addModule({ return addModule({
bundle, bundle,
code: 'transformed bar;', code: 'transformed bar;',
sourceCode: 'source bar', sourceCode: 'source bar',
sourcePath: 'bar path', sourcePath: 'bar path',
}); });
}).then(() => { })
.then(() => {
bundle.finalize({}); bundle.finalize({});
expect(bundle.getSource({dev: true})).toBe([ expect(bundle.getSource({dev: true})).toBe(
[
'transformed foo;', 'transformed foo;',
'transformed bar;', 'transformed bar;',
'\/\/# sourceMappingURL=test_url', '\/\/# sourceMappingURL=test_url',
].join('\n')); ].join('\n'),
);
}); });
}); });
it('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(); const otherBundle = new Bundle();
return Promise.resolve().then(() => { return Promise.resolve()
.then(() => {
return addModule({ return addModule({
bundle: otherBundle, bundle: otherBundle,
code: 'transformed foo;', code: 'transformed foo;',
sourceCode: 'source foo', sourceCode: 'source foo',
sourcePath: 'foo path', sourcePath: 'foo path',
}); });
}).then(() => { })
.then(() => {
return addModule({ return addModule({
bundle: otherBundle, bundle: otherBundle,
code: 'transformed bar;', code: 'transformed bar;',
sourceCode: 'source bar', sourceCode: 'source bar',
sourcePath: 'bar path', sourcePath: 'bar path',
}); });
}).then(() => { })
.then(() => {
otherBundle.finalize({}); otherBundle.finalize({});
expect(otherBundle.getSource({dev: true})).toBe([ expect(otherBundle.getSource({dev: true})).toBe(
'transformed foo;', ['transformed foo;', 'transformed bar;'].join('\n'),
'transformed bar;', );
].join('\n'));
}); });
}); });
it('should create a bundle and add run module code', () => { it('should create a bundle and add run module code', () => {
return Promise.resolve().then(() => { return Promise.resolve()
.then(() => {
return addModule({ return addModule({
bundle, bundle,
code: 'transformed foo;', code: 'transformed foo;',
sourceCode: 'source foo', sourceCode: 'source foo',
sourcePath: 'foo path', sourcePath: 'foo path',
}); });
}).then(() => { })
.then(() => {
return addModule({ return addModule({
bundle, bundle,
code: 'transformed bar;', code: 'transformed bar;',
sourceCode: 'source bar', sourceCode: 'source bar',
sourcePath: 'bar path', sourcePath: 'bar path',
}); });
}).then(() => { })
.then(() => {
bundle.setMainModuleId('foo'); bundle.setMainModuleId('foo');
bundle.finalize({ bundle.finalize({
runBeforeMainModule: ['bar'], runBeforeMainModule: ['bar'],
runModule: true, runModule: true,
}); });
expect(bundle.getSource({dev: true})).toBe([ expect(bundle.getSource({dev: true})).toBe(
[
'transformed foo;', 'transformed foo;',
'transformed bar;', 'transformed bar;',
';require("bar");', ';require("bar");',
';require("foo");', ';require("foo");',
'\/\/# sourceMappingURL=test_url', '\/\/# sourceMappingURL=test_url',
].join('\n')); ].join('\n'),
);
}); });
}); });
it('inserts modules in a deterministic order, independent of timing of the wrapper process', it('inserts modules in a deterministic order, independent of timing of the wrapper process', () => {
() => {
const moduleTransports = [ const moduleTransports = [
createModuleTransport({name: 'module1'}), createModuleTransport({name: 'module1'}),
createModuleTransport({name: 'module2'}), createModuleTransport({name: 'module2'}),
@ -123,11 +136,12 @@ describe('Bundle', () => {
}, },
}; };
const promise = Promise.all(moduleTransports.map( const promise = Promise.all(
m => bundle.addModule(resolver, null, {isPolyfill: () => false}, m) moduleTransports.map(m =>
)).then(() => { bundle.addModule(resolver, null, {isPolyfill: () => false}, m),
expect(bundle.getModules()) ),
.toEqual(moduleTransports); ).then(() => {
expect(bundle.getModules()).toEqual(moduleTransports);
}); });
resolves.module2({code: ''}); resolves.module2({code: ''});
@ -135,8 +149,7 @@ describe('Bundle', () => {
resolves.module1({code: ''}); resolves.module1({code: ''});
return promise; return promise;
}, });
);
}); });
describe('sourcemap bundle', () => { describe('sourcemap bundle', () => {
@ -147,7 +160,8 @@ describe('Bundle', () => {
it('should combine sourcemaps', () => { it('should combine sourcemaps', () => {
const otherBundle = new Bundle({sourceMapUrl: 'test_url'}); const otherBundle = new Bundle({sourceMapUrl: 'test_url'});
return Promise.resolve().then(() => { return Promise.resolve()
.then(() => {
return addModule({ return addModule({
bundle: otherBundle, bundle: otherBundle,
code: 'transformed foo;\n', code: 'transformed foo;\n',
@ -155,7 +169,8 @@ describe('Bundle', () => {
map: {name: 'sourcemap foo'}, map: {name: 'sourcemap foo'},
sourcePath: 'foo path', sourcePath: 'foo path',
}); });
}).then(() => { })
.then(() => {
return addModule({ return addModule({
bundle: otherBundle, bundle: otherBundle,
code: 'transformed bar;\n', code: 'transformed bar;\n',
@ -163,7 +178,8 @@ describe('Bundle', () => {
map: {name: 'sourcemap bar'}, map: {name: 'sourcemap bar'},
sourcePath: 'bar path', sourcePath: 'bar path',
}); });
}).then(() => { })
.then(() => {
return addModule({ return addModule({
bundle: otherBundle, bundle: otherBundle,
code: 'image module;\nimage module;', code: 'image module;\nimage module;',
@ -171,7 +187,8 @@ describe('Bundle', () => {
sourceCode: 'image module;\nimage module;', sourceCode: 'image module;\nimage module;',
sourcePath: 'image.png', sourcePath: 'image.png',
}); });
}).then(() => { })
.then(() => {
otherBundle.setMainModuleId('foo'); otherBundle.setMainModuleId('foo');
otherBundle.finalize({ otherBundle.finalize({
runBeforeMainModule: ['InitializeCore'], runBeforeMainModule: ['InitializeCore'],
@ -248,14 +265,16 @@ describe('Bundle', () => {
describe('getJSModulePaths()', () => { describe('getJSModulePaths()', () => {
it('should return module paths', () => { it('should return module paths', () => {
var otherBundle = new Bundle({sourceMapUrl: 'test_url'}); var otherBundle = new Bundle({sourceMapUrl: 'test_url'});
return Promise.resolve().then(() => { return Promise.resolve()
.then(() => {
return addModule({ return addModule({
bundle: otherBundle, bundle: otherBundle,
code: 'transformed foo;\n', code: 'transformed foo;\n',
sourceCode: 'source foo', sourceCode: 'source foo',
sourcePath: 'foo path', sourcePath: 'foo path',
}); });
}).then(() => { })
.then(() => {
return addModule({ return addModule({
bundle: otherBundle, bundle: otherBundle,
code: 'image module;\nimage module;', code: 'image module;\nimage module;',
@ -263,7 +282,8 @@ describe('Bundle', () => {
sourceCode: 'image module;\nimage module;', sourceCode: 'image module;\nimage module;',
sourcePath: 'image.png', sourcePath: 'image.png',
}); });
}).then(() => { })
.then(() => {
expect(otherBundle.getJSModulePaths()).toEqual(['foo path']); expect(otherBundle.getJSModulePaths()).toEqual(['foo path']);
}); });
}); });
@ -272,7 +292,10 @@ describe('Bundle', () => {
describe('getEtag()', function() { describe('getEtag()', function() {
it('should return an etag', function() { it('should return an etag', function() {
bundle.finalize({}); bundle.finalize({});
var eTag = crypto.createHash('md5').update(bundle.getSource()).digest('hex'); var eTag = crypto
.createHash('md5')
.update(bundle.getSource())
.digest('hex');
expect(bundle.getEtag()).toEqual(eTag); expect(bundle.getEtag()).toEqual(eTag);
}); });
}); });
@ -305,51 +328,86 @@ describe('Bundle', () => {
it('can create a single group', () => { it('can create a single group', () => {
bundle = createBundle([fsLocation('React')]); bundle = createBundle([fsLocation('React')]);
const {groups} = bundle.getUnbundle(); const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([ expect(groups).toEqual(
[idFor('React'), new Set(['ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor))], new Map([
])); [
idFor('React'),
new Set(['ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor)),
],
]),
);
}); });
it('can create two groups', () => { it('can create two groups', () => {
bundle = createBundle([fsLocation('ReactFoo'), fsLocation('ReactBar')]); bundle = createBundle([fsLocation('ReactFoo'), fsLocation('ReactBar')]);
const {groups} = bundle.getUnbundle(); const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([ expect(groups).toEqual(
new Map([
[idFor('ReactFoo'), new Set([idFor('invariant')])], [idFor('ReactFoo'), new Set([idFor('invariant')])],
[idFor('ReactBar'), new Set([idFor('cx')])], [idFor('ReactBar'), new Set([idFor('cx')])],
])); ]),
);
}); });
it('can handle circular dependencies', () => { it('can handle circular dependencies', () => {
bundle = createBundle([fsLocation('OtherFramework')]); bundle = createBundle([fsLocation('OtherFramework')]);
const {groups} = bundle.getUnbundle(); const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([[ expect(groups).toEqual(
new Map([
[
idFor('OtherFramework'), idFor('OtherFramework'),
new Set(['OtherFrameworkFoo', 'invariant', 'OtherFrameworkBar', 'crc32'].map(idFor)), new Set(
]])); [
'OtherFrameworkFoo',
'invariant',
'OtherFrameworkBar',
'crc32',
].map(idFor),
),
],
]),
);
}); });
it('omits modules that are contained by more than one group', () => { it('omits modules that are contained by more than one group', () => {
bundle = createBundle([fsLocation('React'), fsLocation('OtherFramework')]); bundle = createBundle([
fsLocation('React'),
fsLocation('OtherFramework'),
]);
expect(() => { expect(() => {
const {groups} = bundle.getUnbundle(); //eslint-disable-line no-unused-vars const {groups} = bundle.getUnbundle(); //eslint-disable-line no-unused-vars
}).toThrow(new Error(`Module ${fsLocation('invariant')} belongs to groups ${fsLocation('React')}` + }).toThrow(
`, and ${fsLocation('OtherFramework')}. Removing it from all groups.`)); new Error(
`Module ${fsLocation('invariant')} belongs to groups ${fsLocation('React')}` +
`, and ${fsLocation('OtherFramework')}. Removing it from all groups.`,
),
);
}); });
it('ignores missing dependencies', () => { it('ignores missing dependencies', () => {
bundle = createBundle([fsLocation('Product1')]); bundle = createBundle([fsLocation('Product1')]);
const {groups} = bundle.getUnbundle(); const {groups} = bundle.getUnbundle();
expect(groups).toEqual(new Map([[ expect(groups).toEqual(
new Map([
[
idFor('Product1'), idFor('Product1'),
new Set(['React', 'ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor)), new Set(
]])); ['React', 'ReactFoo', 'invariant', 'ReactBar', 'cx'].map(idFor),
),
],
]),
);
}); });
it('throws for group roots that do not exist', () => { it('throws for group roots that do not exist', () => {
bundle = createBundle([fsLocation('DoesNotExist')]); bundle = createBundle([fsLocation('DoesNotExist')]);
expect(() => { expect(() => {
const {groups} = bundle.getUnbundle(); //eslint-disable-line no-unused-vars const {groups} = bundle.getUnbundle(); //eslint-disable-line no-unused-vars
}).toThrow(new Error(`Group root ${fsLocation('DoesNotExist')} is not part of the bundle`)); }).toThrow(
new Error(
`Group root ${fsLocation('DoesNotExist')} is not part of the bundle`,
),
);
}); });
function idFor(name) { function idFor(name) {
@ -397,7 +455,17 @@ function resolverFor(code, map) {
}; };
} }
function addModule({bundle, code, sourceCode, sourcePath, map, virtual, polyfill, meta, id = ''}) { function addModule({
bundle,
code,
sourceCode,
sourcePath,
map,
virtual,
polyfill,
meta,
id = '',
}) {
return bundle.addModule( return bundle.addModule(
resolverFor(code, map), resolverFor(code, map),
null, null,

View File

@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/ */
'use strict'; 'use strict';
@ -46,10 +48,12 @@ describe('transforming JS modules:', () => {
it('passes through file name and code', done => { it('passes through file name and code', done => {
transformModule(sourceCode, options(), (error, result) => { transformModule(sourceCode, options(), (error, result) => {
expect(result.type).toBe('code'); expect(result.type).toBe('code');
expect(result.details).toEqual(expect.objectContaining({ expect(result.details).toEqual(
expect.objectContaining({
code: sourceCode, code: sourceCode,
file: filename, file: filename,
})); }),
);
done(); done();
}); });
}); });
@ -73,11 +77,17 @@ describe('transforming JS modules:', () => {
}); });
it('sets `type` to `"script"` if the input is a polyfill', done => { it('sets `type` to `"script"` if the input is a polyfill', done => {
transformModule(sourceCode, {...options(), polyfill: true}, (error, result) => { transformModule(
sourceCode,
{...options(), polyfill: true},
(error, result) => {
expect(result.type).toBe('code'); expect(result.type).toBe('code');
expect(result.details).toEqual(expect.objectContaining({type: 'script'})); expect(result.details).toEqual(
expect.objectContaining({type: 'script'}),
);
done(); done();
}); },
);
}); });
const defaults = { const defaults = {
@ -89,7 +99,8 @@ describe('transforming JS modules:', () => {
projectRoot: '', projectRoot: '',
}; };
it('calls the passed-in transform function with code, file name, and options ' + it(
'calls the passed-in transform function with code, file name, and options ' +
'for all passed in variants', 'for all passed in variants',
done => { done => {
const variants = {dev: {dev: true}, prod: {dev: false}}; const variants = {dev: {dev: true}, prod: {dev: false}};
@ -127,24 +138,27 @@ describe('transforming JS modules:', () => {
expect(error).toEqual(null); expect(error).toEqual(null);
const {code, dependencyMapName} = result.details.transformed.default; const {code, dependencyMapName} = result.details.transformed.default;
expect(code.replace(/\s+/g, '')) expect(code.replace(/\s+/g, '')).toEqual(
.toEqual( `__d(function(global,require,module,exports,${dependencyMapName}){${transformedCode}});`,
`__d(function(global,require,module,exports,${
dependencyMapName}){${transformedCode}});`
); );
done(); done();
}); });
}); });
it('wraps the code produced by the transform function into an IIFE for polyfills', done => { it('wraps the code produced by the transform function into an IIFE for polyfills', done => {
transformModule(sourceCode, {...options(), polyfill: true}, (error, result) => { transformModule(
sourceCode,
{...options(), polyfill: true},
(error, result) => {
expect(error).toEqual(null); expect(error).toEqual(null);
const {code} = result.details.transformed.default; const {code} = result.details.transformed.default;
expect(code.replace(/\s+/g, '')) expect(code.replace(/\s+/g, '')).toEqual(
.toEqual(`(function(global){${transformedCode}})(this);`); `(function(global){${transformedCode}})(this);`,
);
done(); done();
}); },
);
}); });
it('creates source maps', done => { it('creates source maps', done => {
@ -152,8 +166,9 @@ describe('transforming JS modules:', () => {
const {code, map} = result.details.transformed.default; const {code, map} = result.details.transformed.default;
const column = code.indexOf('code'); const column = code.indexOf('code');
const consumer = new SourceMapConsumer(map); const consumer = new SourceMapConsumer(map);
expect(consumer.originalPositionFor({line: 1, column})) expect(consumer.originalPositionFor({line: 1, column})).toEqual(
.toEqual(expect.objectContaining({line: 1, column: sourceCode.indexOf('code')})); expect.objectContaining({line: 1, column: sourceCode.indexOf('code')}),
);
done(); done();
}); });
}); });
@ -166,8 +181,9 @@ describe('transforming JS modules:', () => {
transformer.transform.stub.returns(transformResult(body)); transformer.transform.stub.returns(transformResult(body));
transformModule(code, options(), (error, result) => { transformModule(code, options(), (error, result) => {
expect(result.details.transformed.default) expect(result.details.transformed.default).toEqual(
.toEqual(expect.objectContaining({dependencies: [dep1, dep2]})); expect.objectContaining({dependencies: [dep1, dep2]}),
);
done(); done();
}); });
}); });
@ -182,15 +198,11 @@ describe('transforming JS modules:', () => {
transformModule(sourceCode, options(variants), (error, result) => { transformModule(sourceCode, options(variants), (error, result) => {
const {dev, prod} = result.details.transformed; const {dev, prod} = result.details.transformed;
expect(dev.code.replace(/\s+/g, '')) expect(dev.code.replace(/\s+/g, '')).toEqual(
.toEqual( `__d(function(global,require,module,exports,${dev.dependencyMapName}){arbitrary(code);});`,
`__d(function(global,require,module,exports,${
dev.dependencyMapName}){arbitrary(code);});`
); );
expect(prod.code.replace(/\s+/g, '')) expect(prod.code.replace(/\s+/g, '')).toEqual(
.toEqual( `__d(function(global,require,module,exports,${prod.dependencyMapName}){arbitrary(code);});`,
`__d(function(global,require,module,exports,${
prod.dependencyMapName}){arbitrary(code);});`
); );
done(); done();
}); });
@ -199,23 +211,31 @@ describe('transforming JS modules:', () => {
it('prefixes JSON files with `module.exports = `', done => { it('prefixes JSON files with `module.exports = `', done => {
const json = '{"foo":"bar"}'; const json = '{"foo":"bar"}';
transformModule(json, {...options(), filename: 'some.json'}, (error, result) => { transformModule(
json,
{...options(), filename: 'some.json'},
(error, result) => {
const {code} = result.details.transformed.default; const {code} = result.details.transformed.default;
expect(code.replace(/\s+/g, '')) expect(code.replace(/\s+/g, '')).toEqual(
.toEqual(
'__d(function(global,require,module,exports){' + '__d(function(global,require,module,exports){' +
`module.exports=${json}});` `module.exports=${json}});`,
); );
done(); done();
}); },
);
}); });
it('does not create source maps for JSON files', done => { it('does not create source maps for JSON files', done => {
transformModule('{}', {...options(), filename: 'some.json'}, (error, result) => { transformModule(
expect(result.details.transformed.default) '{}',
.toEqual(expect.objectContaining({map: null})); {...options(), filename: 'some.json'},
(error, result) => {
expect(result.details.transformed.default).toEqual(
expect.objectContaining({map: null}),
);
done(); done();
}); },
);
}); });
it('adds package data for `package.json` files', done => { it('adds package data for `package.json` files', done => {

View File

@ -7,6 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
* *
* @flow * @flow
* @format
*/ */
'use strict'; 'use strict';
@ -70,12 +71,13 @@ function transformModule(
const {filename, transformer, variants = defaultVariants} = options; const {filename, transformer, variants = defaultVariants} = options;
const tasks = {}; const tasks = {};
Object.keys(variants).forEach(name => { Object.keys(variants).forEach(name => {
tasks[name] = asyncify(() => transformer.transform({ tasks[name] = asyncify(() =>
transformer.transform({
filename, filename,
localPath: filename, localPath: filename,
options: {...defaultTransformOptions, ...variants[name]}, options: {...defaultTransformOptions, ...variants[name]},
src: code, src: code,
}) }),
); );
}); });
@ -89,7 +91,12 @@ function transformModule(
//$FlowIssue #14545724 //$FlowIssue #14545724
Object.entries(results).forEach(([key, value]: [*, TransformFnResult]) => { Object.entries(results).forEach(([key, value]: [*, TransformFnResult]) => {
transformed[key] = makeResult(value.ast, filename, code, options.polyfill); transformed[key] = makeResult(
value.ast,
filename,
code,
options.polyfill,
);
}); });
const annotations = docblock.parseAsObject(docblock.extract(code)); const annotations = docblock.parseAsObject(docblock.extract(code));
@ -112,10 +119,7 @@ function transformModule(
function transformJSON(json, options, callback) { function transformJSON(json, options, callback) {
const value = JSON.parse(json); const value = JSON.parse(json);
const {filename} = options; const {filename} = options;
const code = const code = `__d(function(${JsFileWrapping.MODULE_FACTORY_PARAMETERS.join(', ')}) { module.exports = \n${json}\n});`;
`__d(function(${JsFileWrapping.MODULE_FACTORY_PARAMETERS.join(', ')}) { module.exports = \n${
json
}\n});`;
const moduleData = { const moduleData = {
code, code,
@ -124,9 +128,9 @@ function transformJSON(json, options, callback) {
}; };
const transformed = {}; const transformed = {};
Object Object.keys(options.variants || defaultVariants).forEach(
.keys(options.variants || defaultVariants) key => (transformed[key] = moduleData),
.forEach(key => (transformed[key] = moduleData)); );
const result: TransformedCodeFile = { const result: TransformedCodeFile = {
assetContent: null, assetContent: null,

View File

@ -5,6 +5,8 @@
* This source code is licensed under the BSD-style license found in the * This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant * LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory. * of patent rights can be found in the PATENTS file in the same directory.
*
* @format
*/ */
'use strict'; 'use strict';
@ -35,15 +37,14 @@ it('symbolicates stack frames', () => {
]; ];
const stack = mappings.map(m => m.to); const stack = mappings.map(m => m.to);
const maps = const maps = Object.entries(
Object.entries(groupBy(mappings, m => m.from.file)) groupBy(mappings, m => m.from.file),
.map(([file, ms]) => [file, sourceMap(file, ms)]); ).map(([file, ms]) => [file, sourceMap(file, ms)]);
return symbolicate(connection, makeData(stack, maps)) return symbolicate(connection, makeData(stack, maps)).then(() =>
.then(() =>
expect(connection.end).toBeCalledWith( expect(connection.end).toBeCalledWith(
JSON.stringify({result: mappings.map(m => m.to)}) JSON.stringify({result: mappings.map(m => m.to)}),
) ),
); );
}); });
@ -54,11 +55,11 @@ it('ignores stack frames without corresponding map', () => {
column: 456, column: 456,
}; };
return symbolicate(connection, makeData([frame], [['other.js', emptyMap()]])) return symbolicate(
.then(() => connection,
expect(connection.end).toBeCalledWith( makeData([frame], [['other.js', emptyMap()]]),
JSON.stringify({result: [frame]}) ).then(() =>
) expect(connection.end).toBeCalledWith(JSON.stringify({result: [frame]})),
); );
}); });
@ -69,11 +70,8 @@ it('ignores `/debuggerWorker.js` stack frames', () => {
column: 456, column: 456,
}; };
return symbolicate(connection, makeData([frame])) return symbolicate(connection, makeData([frame])).then(() =>
.then(() => expect(connection.end).toBeCalledWith(JSON.stringify({result: [frame]})),
expect(connection.end).toBeCalledWith(
JSON.stringify({result: [frame]})
)
); );
}); });
@ -85,7 +83,8 @@ function sourceMap(file, mappings) {
const g = new SourceMapGenerator(); const g = new SourceMapGenerator();
g.startFile(file, null); g.startFile(file, null);
mappings.forEach(({from, to}) => mappings.forEach(({from, to}) =>
g.addSourceMapping(to.lineNumber, to.column, from.lineNumber, from.column)); g.addSourceMapping(to.lineNumber, to.column, from.lineNumber, from.column),
);
return g.toMap(); return g.toMap();
} }