MCPcopy
hub / github.com/mozilla/source-map / test

Function test

test/test-source-node.js:357–376  ·  view source on GitHub ↗
(relativePath, expectedSources)

Source from the content-addressed store, hash-verified

355 const foo = new SourceNode(1, 0, "foo.js", "foo(js);");
356
357 const test = async function (relativePath, expectedSources) {
358 const app = new SourceNode();
359
360 const map = await new SourceMapConsumer(coffeeBundle.map.toString());
361 app.add(
362 SourceNode.fromStringWithSourceMap(coffeeBundle.code, map, relativePath)
363 );
364 map.destroy();
365
366 app.add(foo);
367 let i = 0;
368 app.walk(function (chunk, loc) {
369 assert.equal(loc.source, expectedSources[i]);
370 i++;
371 });
372 app.walkSourceContents(function (sourceFile, sourceContent) {
373 assert.equal(sourceFile, expectedSources[0]);
374 assert.equal(sourceContent, "foo coffee");
375 });
376 };
377
378 await test("../coffee/maps", ["../coffee/foo.coffee", "foo.js"]);
379

Callers 1

Calls 6

addMethod · 0.95
walkMethod · 0.95
walkSourceContentsMethod · 0.95
destroyMethod · 0.65
toStringMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…