Skip to content
This repository was archived by the owner on Sep 21, 2021. It is now read-only.

Commit 95924ca

Browse files
authored
Merge pull request #486 from devtools-html/devtools-core/source-map-equality
Fix equality check
1 parent ef30dc9 commit 95924ca

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

packages/devtools-source-map/src/tests/source-map.js

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,34 @@ const fs = require("fs");
66
const path = require("path");
77

88
jest.mock("devtools-utils/src/network-request");
9-
const { getOriginalURLs } = require("../source-map");
9+
const { getOriginalURLs, hasMappedSource } = require("../source-map");
1010

1111
function getMap(_path) {
1212
const mapPath = path.join(__dirname, _path);
1313
return fs.readFileSync(mapPath, "utf8");
1414
}
1515

16+
async function setupBundleFixture() {
17+
const source = {
18+
id: "bundle.js",
19+
sourceMapURL: "bundle.js.map",
20+
url: "http:://example.com/bundle.js"
21+
};
22+
23+
require("devtools-utils/src/network-request").mockImplementationOnce(() => {
24+
const content = getMap("fixtures/bundle.js.map");
25+
return { content };
26+
});
27+
28+
await getOriginalURLs(source);
29+
}
30+
1631
describe("source maps", () => {
1732
test("getOriginalURLs", async () => {
1833
const source = {
1934
id: "bundle.js",
2035
sourceMapURL: "bundle.js.map",
21-
url: "http:://example.com/bundle.js",
36+
url: "http:://example.com/bundle.js"
2237
};
2338

2439
require("devtools-utils/src/network-request").mockImplementationOnce(() => {
@@ -88,4 +103,25 @@ describe("source maps", () => {
88103
"http://example.com/whatever/heart.js"
89104
]);
90105
});
106+
107+
describe("hasMappedSource", async () => {
108+
test("has original location", async () => {
109+
await setupBundleFixture()
110+
const location = {
111+
sourceId: "bundle.js",
112+
line: 49
113+
};
114+
const isMappaed = await hasMappedSource(location);
115+
expect(isMappaed).toBe(true);
116+
})
117+
118+
test("does not have original location", async () => {
119+
const location = {
120+
sourceId: "bundle.js",
121+
line: 94
122+
};
123+
const isMappaed = await hasMappedSource(location);
124+
expect(isMappaed).toBe(false);
125+
})
126+
});
91127
});

0 commit comments

Comments
 (0)