Skip to content

Commit f9dc9aa

Browse files
italojsmabaasit
authored andcommitted
test: improve code coverage for SourceMap class
Cover malformed mappings scenario. PR-URL: nodejs#43285 Reviewed-By: Ben Coe <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 0dba66d commit f9dc9aa

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/parallel/test-source-map-api.js

+14
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,20 @@ const { readFileSync } = require('fs');
9999
assert.notStrictEqual(payload.sources, sourceMap.payload.sources);
100100
}
101101

102+
// findEntry() must return empty object instead error when
103+
// receive a malformed mappings.
104+
{
105+
const payload = JSON.parse(readFileSync(
106+
require.resolve('../fixtures/source-map/disk.map'), 'utf8'
107+
));
108+
payload.mappings = ';;;;;;;;;';
109+
110+
const sourceMap = new SourceMap(payload);
111+
const result = sourceMap.findEntry(0, 5);
112+
assert.strictEqual(typeof result, 'object');
113+
assert.strictEqual(Object.keys(result).length, 0);
114+
}
115+
102116
// Test various known decodings to ensure decodeVLQ works correctly.
103117
{
104118
function makeMinimalMap(column) {

0 commit comments

Comments
 (0)