From 40826822e93ed1fa39b48530520e4e978f51adca Mon Sep 17 00:00:00 2001 From: David Stensland Date: Wed, 8 May 2019 13:30:17 -0700 Subject: [PATCH] add test for not loading SourceMaps in strings --- test/fixtures/normal-file2.js | 3 +++ test/index.test.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/normal-file2.js diff --git a/test/fixtures/normal-file2.js b/test/fixtures/normal-file2.js new file mode 100644 index 0000000..85a6f48 --- /dev/null +++ b/test/fixtures/normal-file2.js @@ -0,0 +1,3 @@ +without SourceMap +anInvalidDirective = "\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+" */"; +// comment diff --git a/test/index.test.js b/test/index.test.js index 1191e24..03a5f1f 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -54,6 +54,17 @@ describe("source-map-loader", function() { }); }); + it("should not process source maps in strings", function(done) { + execLoader(path.join(fixturesPath, "normal-file2.js"), function(err, res, map, deps, warns) { + should.equal(err, null); + warns.should.be.eql([]); + should.equal(res, "without SourceMap\nanInvalidDirective = \"\\n/*# sourceMappingURL=data:application/json;base64,\"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+\" */\";\n// comment"), + should.equal(map, null); + deps.should.be.eql([]); + done(); + }); + }); + it("should process inlined SourceMaps", function(done) { execLoader(path.join(fixturesPath, "inline-source-map.js"), function(err, res, map, deps, warns) { should.equal(err, null); @@ -304,4 +315,4 @@ describe("source-map-loader", function() { } ); }); -}); \ No newline at end of file +});