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

Function testTransitiveMappingAction

test/test-spec-tests.js:125–171  ·  view source on GitHub ↗
(assert, rawSourceMap, action)

Source from the content-addressed store, hash-verified

123}
124
125async function testTransitiveMappingAction(assert, rawSourceMap, action) {
126 return SourceMapConsumer.with(rawSourceMap, null, async consumer => {
127 assert.ok(
128 Array.isArray(action.intermediateMaps),
129 "transitive mapping case requires intermediate maps"
130 );
131
132 let mappedPosition = consumer.originalPositionFor({
133 line: mapLine(action.generatedLine),
134 column: action.generatedColumn,
135 });
136
137 for (const intermediateMapPath of action.intermediateMaps) {
138 const intermediateMap = await readJSON(
139 `./source-map-tests/resources/${intermediateMapPath}`
140 );
141 await SourceMapConsumer.with(
142 intermediateMap,
143 null,
144 consumerIntermediate => {
145 mappedPosition = consumerIntermediate.originalPositionFor({
146 line: mappedPosition.line,
147 column: mappedPosition.column,
148 });
149 }
150 );
151 }
152
153 assert.equal(
154 mappedPosition.line,
155 mapLine(action.originalLine),
156 `original line didn't match, expected ${mapLine(
157 action.originalLine
158 )} got ${mappedPosition.line}`
159 );
160 assert.equal(
161 mappedPosition.column,
162 action.originalColumn,
163 `original column didn't match, expected ${action.originalColumn} got ${mappedPosition.column}`
164 );
165 assert.equal(
166 mappedPosition.source,
167 action.originalSource,
168 `original source didn't match, expected ${action.originalSource} got ${mappedPosition.source}`
169 );
170 });
171}
172
173for (const testCase of sourceMapSpecTests.tests) {
174 if (skippedTests.includes(testCase.name)) {

Callers 1

test-spec-tests.jsFile · 0.85

Calls 4

mapLineFunction · 0.85
readJSONFunction · 0.85
withMethod · 0.65
originalPositionForMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…