UNPKG

1.92 kBJavaScriptView Raw
1// Load in our dependencies
2var assert = require('assert');
3var request = require('request');
4var convertSourceMap = require('convert-source-map');
5
6// Start our tests
7describe('A file with a source map loaded with karma-electron', function () {
8 before(function retrieveHttpFile (done) {
9 // Retrieve karma-electron processed HTTP body
10 var that = this;
11 request('http://localhost:9876/base/source-map-test.js', function handleRequest (err, res, body) {
12 that.httpBody = body;
13 done(err);
14 });
15 });
16 after(function cleanup () {
17 delete this.httpBody;
18 });
19
20 it('extends its source map', function () {
21 // Load in our HTTP lines
22 var generatedContent = this.httpBody;
23 var generatedSourcemap = convertSourceMap.fromComment(generatedContent).toObject();
24
25 // Verify our source map's contents are in the source map
26 // {version: 3, sources: ['/home/todd/.../_node-integration-iframe.mustache.js/path/to/source-map-test.js', ...],
27 // names: [], mappings: 'AAAA;...', file: 'generated.js',
28 // sourceRoot: '', sourcesContent: ['(function () {...', ...]}
29 assert.strictEqual(generatedSourcemap.sources.length, 2);
30 assert.strictEqual(generatedSourcemap.sources[1], '/src/foo.js');
31 assert.strictEqual(generatedSourcemap.sourcesContent.length, 2);
32 assert.strictEqual(generatedSourcemap.sourcesContent[1], 'console.log(\'hi\');');
33 });
34});
35// Via https://github.com/thlorenz/convert-source-map
36// jscs:disable
37// Generated via: echo '{"version":3,"file":"build/foo.min.js","sources":["src/foo.js"],"names":[],"mappings":"AAAA","sourceRoot":"/","sourcesContent":["console.log(\"hi\");"]}' | base64
38//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVpbGQvZm9vLm1pbi5qcyIsInNvdXJjZXMiOlsic3JjL2Zvby5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSIsInNvdXJjZVJvb3QiOiIvIiwic291cmNlc0NvbnRlbnQiOlsiY29uc29sZS5sb2coJ2hpJyk7Il19Cg==