Skip to content

Commit

Permalink
test: improve code coverage for SourceMap class
Browse files Browse the repository at this point in the history
Cover malformed mappings scenario.

PR-URL: #43285
Reviewed-By: Ben Coe <bencoe@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
italojs authored and targos committed Jul 12, 2022
1 parent 7c6f548 commit 705e85e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/parallel/test-source-map-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ const { readFileSync } = require('fs');
assert.notStrictEqual(payload.sources, sourceMap.payload.sources);
}

// findEntry() must return empty object instead error when
// receive a malformed mappings.
{
const payload = JSON.parse(readFileSync(
require.resolve('../fixtures/source-map/disk.map'), 'utf8'
));
payload.mappings = ';;;;;;;;;';

const sourceMap = new SourceMap(payload);
const result = sourceMap.findEntry(0, 5);
assert.strictEqual(typeof result, 'object');
assert.strictEqual(Object.keys(result).length, 0);
}

// Test various known decodings to ensure decodeVLQ works correctly.
{
function makeMinimalMap(column) {
Expand Down

0 comments on commit 705e85e

Please sign in to comment.