Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b64f7d8
commit 4c39c22
Showing
7 changed files
with
211 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`source-map-loader should be null: result 1`] = `null`; | ||
|
||
exports[`source-map-loader should be null: result 2`] = `null`; | ||
|
||
exports[`source-map-loader should find last map: result 1`] = `"/sample-source-map-last.map"`; | ||
|
||
exports[`source-map-loader should not include quotes: result 1`] = `"data:application/json;base64,"`; | ||
|
||
exports[`source-map-loader should work: result 1`] = `"absolute-sourceRoot-source-map.map"`; | ||
|
||
exports[`source-map-loader should work: result 2`] = `"absolute-sourceRoot-source-map.map"`; | ||
|
||
exports[`source-map-loader should work: result 3`] = `"absolute-sourceRoot-source-map.map"`; | ||
|
||
exports[`source-map-loader should work: result 4`] = `"absolute-sourceRoot-source-map.map"`; | ||
|
||
exports[`source-map-loader should work: result 5`] = `"absolute-sourceRoot-source-map.map"`; | ||
|
||
exports[`source-map-loader should work: result 6`] = `"absolute-sourceRoot-source-map.map"`; | ||
|
||
exports[`source-map-loader should work: result 7`] = `"http://sampledomain.com/external-source-map2.map"`; | ||
|
||
exports[`source-map-loader should work: result 8`] = `"data:application/source-map;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lLXNvdXJjZS1tYXAuanMiLCJzb3VyY2VzIjpbImlubGluZS1zb3VyY2UtbWFwLnR4dCJdLCJzb3VyY2VzQ29udGVudCI6WyJ3aXRoIFNvdXJjZU1hcCJdLCJtYXBwaW5ncyI6IkFBQUEifQ=="`; | ||
|
||
exports[`source-map-loader should work: result 9`] = `"/sample-source-map.map"`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// without SourceMap | ||
anInvalidDirective = "\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+" */"; | ||
// comment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
import { getSourceMappingUrl } from '../src/utils'; | ||
|
||
describe('source-map-loader', () => { | ||
it('should work', async () => { | ||
const code = `/*#sourceMappingURL=absolute-sourceRoot-source-map.map*/`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = `/* #sourceMappingURL=absolute-sourceRoot-source-map.map */`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = `//#sourceMappingURL=absolute-sourceRoot-source-map.map`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = `//@sourceMappingURL=absolute-sourceRoot-source-map.map`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = ` // #sourceMappingURL=absolute-sourceRoot-source-map.map`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = ` // # sourceMappingURL = absolute-sourceRoot-source-map.map `; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = `// #sourceMappingURL = http://sampledomain.com/external-source-map2.map`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = `// @sourceMappingURL=data:application/source-map;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5saW5lLXNvdXJjZS1tYXAuanMiLCJzb3VyY2VzIjpbImlubGluZS1zb3VyY2UtbWFwLnR4dCJdLCJzb3VyY2VzQ29udGVudCI6WyJ3aXRoIFNvdXJjZU1hcCJdLCJtYXBwaW5ncyI6IkFBQUEifQ==`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should work', async () => { | ||
const code = ` | ||
with SourceMap | ||
// #sourceMappingURL = /sample-source-map.map | ||
// comment | ||
`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should find last map', async () => { | ||
const code = ` | ||
with SourceMap | ||
// #sourceMappingURL = /sample-source-map-1.map | ||
// #sourceMappingURL = /sample-source-map-2.map | ||
// #sourceMappingURL = /sample-source-map-last.map | ||
// comment | ||
`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should be null', async () => { | ||
const code = `" | ||
/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+" */";`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should be null', async () => { | ||
const code = `anInvalidDirective = "\\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+" */";`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
|
||
it('should not include quotes', async () => { | ||
const code = `// # sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))))+"`; | ||
const { url } = getSourceMappingUrl(code); | ||
|
||
expect(url).toMatchSnapshot('result'); | ||
}); | ||
}); |