This repository has been archived by the owner on Aug 2, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
60 lines (51 loc) · 1.78 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* global describe, it */
"use strict";
let extractSourcemap = require(".");
let assert = require("assert");
describe("extract-sourcemap", _ => {
it("extracts a sourcemap with charset", () => {
let source = `
.blubb {
display: -ms-flexbox;
display: flex; }
.bla {
color: green; }
/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9zcmMvaW5kZXguc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQTtFQUNDLHFCQUFhO0VBQWIsY0FBYSxFQUNiOztBQUVEO0VBQ0MsYUFQWSxFQVFaIiwiZmlsZSI6InNyYy9pbmRleC5zY3NzIn0= */
`;
let map = extractSourcemap(source, ["version"]);
assert.deepEqual(map, { "version": 3 });
});
it("extracts a sourcemap without charset", () => {
let source = `
.blubb {
display: -ms-flexbox;
display: flex; }
.bla {
color: green; }
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbInNyYy9zcmMvaW5kZXguc2NzcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQTtFQUNDLHFCQUFhO0VBQWIsY0FBYSxFQUNiOztBQUVEO0VBQ0MsYUFQWSxFQVFaIiwiZmlsZSI6InNyYy9pbmRleC5zY3NzIn0= */
`;
let map = extractSourcemap(source, ["version"]);
assert.deepEqual(map, { "version": 3 });
});
it("fails to extract a sourcemap without base64 content", () => {
let source = `
.blubb {
display: -ms-flexbox;
display: flex; }
.bla {
color: green; }
/*# sourceMappingURL=data:application/json;,"This is not base64" */
`;
assert.throws(() => extractSourcemap(source, ["version"]), Error, "No Source Map found");
});
it("fails to extract a missing sourcemap", () => {
let source = `
.blubb {
display: -ms-flexbox;
display: flex; }
.bla {
color: green; }
`;
assert.throws(() => extractSourcemap(source, ["version"]), Error, "No Source Map found");
});
});