diff options
Diffstat (limited to 'node_modules/convert-source-map/test')
7 files changed, 469 insertions, 0 deletions
diff --git a/node_modules/convert-source-map/test/comment-regex.js b/node_modules/convert-source-map/test/comment-regex.js new file mode 100644 index 000000000..16331ccb8 --- /dev/null +++ b/node_modules/convert-source-map/test/comment-regex.js @@ -0,0 +1,138 @@ +'use strict'; +/*jshint asi: true */ + +var test = require('tap').test + , generator = require('inline-source-map') + , rx = require('..').commentRegex + , mapFileRx = require('..').mapFileCommentRegex + +function comment(prefix, suffix) { + rx.lastIndex = 0; + return rx.test(prefix + 'sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix) +} + +function commentWithCharSet(prefix, suffix, sep) { + sep = sep || ':'; + rx.lastIndex = 0; + return rx.test(prefix + 'sourceMappingURL=data:application/json;charset' + sep +'utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + suffix) +} + +// Source Map v2 Tests +test('comment regex old spec - @', function (t) { + [ + '//@ ', + ' //@ ', // with leading space + '\t//@ ', // with leading tab + '//@ ', // with leading text + '/*@ ', // multi line style + ' /*@ ', // multi line style with leading spaces + '\t/*@ ', // multi line style with leading tab + '/*@ ', // multi line style with leading text + ].forEach(function (x) { + t.ok(comment(x, ''), 'matches ' + x) + t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset') + t.ok(commentWithCharSet(x, '', '='), 'matches ' + x + ' with charset') + }); + + [ + ' @// @', + ' @/* @', + ].forEach(function (x) { t.ok(!comment(x, ''), 'should not match ' + x) }) + + t.end() +}) + +test('comment regex new spec - #', function (t) { + [ + ' //# ', // with leading spaces + '\t//# ', // with leading tab + '//# ', // with leading text + '/*# ', // multi line style + ' /*# ', // multi line style with leading spaces + '\t/*# ', // multi line style with leading tab + '/*# ', // multi line style with leading text + ].forEach(function (x) { + t.ok(comment(x, ''), 'matches ' + x) + t.ok(commentWithCharSet(x, ''), 'matches ' + x + ' with charset') + t.ok(commentWithCharSet(x, '', '='), 'matches ' + x + ' with charset') + }); + + [ + ' #// #', + ' #/* #', + ].forEach(function (x) { t.ok(!comment(x, ''), 'should not match ' + x) }) + + t.end() +}) + +function mapFileCommentWrap(s1, s2) { + mapFileRx.lastIndex = 0; + return mapFileRx.test(s1 + 'sourceMappingURL=foo.js.map' + s2) +} + +test('mapFileComment regex old spec - @', function (t) { + + [ + ['//@ ', ''], + [' //@ ', ''], // with leading spaces + ['\t//@ ', ''], // with a leading tab + ['///@ ', ''], // with a leading text + [';//@ ', ''], // with a leading text + ['return//@ ', ''], // with a leading text + ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) }); + + [ + [' @// @', ''], + ['var sm = "//@ ', '"'], // not inside a string + ['var sm = \'//@ ', '\''], // not inside a string + ['var sm = \' //@ ', '\''], // not inside a string + ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) }) + t.end() +}) + +test('mapFileComment regex new spec - #', function (t) { + [ + ['//# ', ''], + [' //# ', ''], // with leading space + ['\t//# ', ''], // with leading tab + ['///# ', ''], // with leading text + [';//# ', ''], // with leading text + ['return//# ', ''], // with leading text + ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) }); + + [ + [' #// #', ''], + ['var sm = "//# ', '"'], // not inside a string + ['var sm = \'//# ', '\''], // not inside a string + ['var sm = \' //# ', '\''], // not inside a string + ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) }) + t.end() +}) + +test('mapFileComment regex /* */ old spec - @', function (t) { + [ [ '/*@ ', '*/' ] + , [' /*@ ', ' */ ' ] // with leading spaces + , [ '\t/*@ ', ' \t*/\t '] // with a leading tab + , [ 'leading string/*@ ', '*/' ] // with a leading string + , [ '/*@ ', ' \t*/\t '] // with trailing whitespace + ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) }); + + [ ['/*@ ', ' */ */ ' ], // not the last thing on its line + ['/*@ ', ' */ more text ' ] // not the last thing on its line + ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) }); + t.end() +}) + +test('mapFileComment regex /* */ new spec - #', function (t) { + [ [ '/*# ', '*/' ] + , [' /*# ', ' */ ' ] // with leading spaces + , [ '\t/*# ', ' \t*/\t '] // with a leading tab + , [ 'leading string/*# ', '*/' ] // with a leading string + , [ '/*# ', ' \t*/\t '] // with trailing whitespace + ].forEach(function (x) { t.ok(mapFileCommentWrap(x[0], x[1]), 'matches ' + x.join(' :: ')) }); + + [ ['/*# ', ' */ */ ' ], // not the last thing on its line + ['/*# ', ' */ more text ' ] // not the last thing on its line + ].forEach(function (x) { t.ok(!mapFileCommentWrap(x[0], x[1]), 'does not match ' + x.join(' :: ')) }); + t.end() +}) diff --git a/node_modules/convert-source-map/test/convert-source-map.js b/node_modules/convert-source-map/test/convert-source-map.js new file mode 100644 index 000000000..ea243f5f7 --- /dev/null +++ b/node_modules/convert-source-map/test/convert-source-map.js @@ -0,0 +1,213 @@ +'use strict'; +/*jshint asi: true */ + +var test = require('tap').test + , generator = require('inline-source-map') + , convert = require('..') + +var gen = generator() + .addMappings('foo.js', [{ original: { line: 2, column: 3 } , generated: { line: 5, column: 10 } }], { line: 5 }) + .addGeneratedMappings('bar.js', 'var a = 2;\nconsole.log(a)', { line: 23, column: 22 }) + + , base64 = gen.base64Encode() + , comment = gen.inlineMappingUrl() + , json = gen.toString() + , obj = JSON.parse(json) + +test('different formats', function (t) { + + t.equal(convert.fromComment(comment).toComment(), comment, 'comment -> comment') + t.equal(convert.fromComment(comment).toBase64(), base64, 'comment -> base64') + t.equal(convert.fromComment(comment).toJSON(), json, 'comment -> json') + t.deepEqual(convert.fromComment(comment).toObject(), obj, 'comment -> object') + + t.equal(convert.fromBase64(base64).toBase64(), base64, 'base64 -> base64') + t.equal(convert.fromBase64(base64).toComment(), comment, 'base64 -> comment') + t.equal(convert.fromBase64(base64).toJSON(), json, 'base64 -> json') + t.deepEqual(convert.fromBase64(base64).toObject(), obj, 'base64 -> object') + + t.equal(convert.fromJSON(json).toJSON(), json, 'json -> json') + t.equal(convert.fromJSON(json).toBase64(), base64, 'json -> base64') + t.equal(convert.fromJSON(json).toComment(), comment, 'json -> comment') + t.deepEqual(convert.fromJSON(json).toObject(), obj, 'json -> object') + t.end() +}) + +test('to object returns a copy', function (t) { + var c = convert.fromJSON(json) + var o = c.toObject() + o.version = '99'; + t.equal(c.toObject().version, 3, 'setting property on returned object does not affect original') + t.end() +}) + +test('to multi-line map', function (t) { + var c = convert.fromObject(obj); + var s = c.toComment({ multiline: true }); + t.similar(s, /^\/\*# sourceMappingURL=.+ \*\/$/); + t.end(); +}) + +test('to map file comment', function (t) { + t.equal(convert.generateMapFileComment('index.js.map'), '//# sourceMappingURL=index.js.map'); + t.equal(convert.generateMapFileComment('index.css.map', { multiline: true }), '/*# sourceMappingURL=index.css.map */'); + t.end(); +}) + +test('from source', function (t) { + var foo = [ + 'function foo() {' + , ' console.log("hello I am foo");' + , ' console.log("who are you");' + , '}' + , '' + , 'foo();' + , '' + ].join('\n') + , map = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , otherMap = '//# sourceMappingURL=data:application/json;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + + function getComment(src) { + var map = convert.fromSource(src); + return map ? map.toComment() : null; + } + + t.equal(getComment(foo), null, 'no comment returns null') + t.equal(getComment(foo + map), map, 'beginning of last line') + t.equal(getComment(foo + ' ' + map), map, 'indented of last line') + t.equal(getComment(foo + ' ' + map + '\n\n'), map, 'indented on last non empty line') + t.equal(getComment(foo + map + '\nconsole.log("more code");\nfoo()\n'), map, 'in the middle of code') + t.equal(getComment(foo + otherMap + '\n' + map), map, 'finds last map in source') + t.end() +}) + +test('from source with a large source', function (t) { + var foo = [ + 'function foo() {' + , ' console.log("hello I am foo");' + , ' console.log("who are you");' + , '}' + , '' + , 'foo();' + , '' + ].join('\n') + , map = '//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , otherMap = '//# sourceMappingURL=data:application/json;base64,otherZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + + function getComment(src) { + var map = convert.fromSource(src, true); + return map ? map.toComment() : null; + } + + t.equal(getComment(foo), null, 'no comment returns null') + t.equal(getComment(foo + map), map, 'beginning of last line') + t.equal(getComment(foo + ' ' + map), map, 'indented of last line') + t.equal(getComment(foo + ' ' + map + '\n\n'), map, 'indented on last non empty line') + t.equal(getComment(foo + map + '\nconsole.log("more code");\nfoo()\n'), map, 'in the middle of code') + t.equal(getComment(foo + otherMap + '\n' + map), map, 'finds last map in source') + t.end() +}) + +test('remove comments', function (t) { + var foo = [ + 'function foo() {' + , ' console.log("hello I am foo");' + , ' console.log("who are you");' + , '}' + , '' + , 'foo();' + , '' + ].join('\n') + // this one is old spec on purpose + , map = '//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , otherMap = '//# sourceMappingURL=data:application/json;base64,ZXJzaW9uIjozLCJmaWxlIjoiIiwic291cmNlcyI6WyJmdW5jdGlvbiBmb28oKSB7XG4gY29uc29sZS5sb2coXCJoZWxsbyBJIGFtIGZvb1wiKTtcbiBjb25zb2xlLmxvZyhcIndobyBhcmUgeW91XCIpO1xufVxuXG5mb28oKTtcbiJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9' + , extraCode = '\nconsole.log("more code");\nfoo()\n' + + t.equal(convert.removeComments(foo + map), foo, 'from last line') + t.equal(convert.removeComments(foo + map + extraCode), foo + extraCode, 'from the middle of code') + t.equal(convert.removeComments(foo + otherMap + extraCode + map), foo + extraCode, 'multiple comments from the middle of code') + t.end() +}) + +test('remove map file comments', function (t) { + var foo = [ + 'function foo() {' + , ' console.log("hello I am foo");' + , ' console.log("who are you");' + , '}' + , '' + , 'foo();' + , '' + ].join('\n') + , fileMap1 = '//# sourceMappingURL=foo.js.map' + , fileMap2 = '/*# sourceMappingURL=foo.js.map */'; + + t.equal(convert.removeMapFileComments(foo + fileMap1), foo, '// style filemap comment') + t.equal(convert.removeMapFileComments(foo + fileMap2), foo, '/* */ style filemap comment') + t.end() +}) + +test('pretty json', function (t) { + var mod = convert.fromJSON(json).toJSON(2) + , expected = JSON.stringify(obj, null, 2); + + t.equal( + mod + , expected + , 'pretty prints json when space is given') + t.end() +}) + +test('adding properties', function (t) { + var mod = convert + .fromJSON(json) + .addProperty('foo', 'bar') + .toJSON() + , expected = JSON.parse(json); + expected.foo = 'bar'; + t.equal( + mod + , JSON.stringify(expected) + , 'includes added property' + ) + t.end() +}) + +test('setting properties', function (t) { + var mod = convert + .fromJSON(json) + .setProperty('version', '2') + .setProperty('mappings', ';;;UACG') + .setProperty('should add', 'this') + .toJSON() + , expected = JSON.parse(json); + expected.version = '2'; + expected.mappings = ';;;UACG'; + expected['should add'] = 'this'; + t.equal( + mod + , JSON.stringify(expected) + , 'includes new property and changes existing properties' + ) + t.end() +}) + +test('getting properties', function (t) { + var sm = convert.fromJSON(json) + + t.equal(sm.getProperty('version'), 3, 'gets version') + t.deepEqual(sm.getProperty('sources'), ['foo.js', 'bar.js'], 'gets sources') + t.end() +}) + +test('return null fromSource when largeSource is true', function(t) { + var mod = convert.fromSource('', true) + , expected = null; + + t.equal( + mod + , expected + , 'return value should be null' + ) + t.end() +}) diff --git a/node_modules/convert-source-map/test/fixtures/map-file-comment-double-slash.css b/node_modules/convert-source-map/test/fixtures/map-file-comment-double-slash.css new file mode 100644 index 000000000..e77799167 --- /dev/null +++ b/node_modules/convert-source-map/test/fixtures/map-file-comment-double-slash.css @@ -0,0 +1,14 @@ +.header { + background: #444; + border: solid; + padding: 10px; + border-radius: 10px 5px 10px 5px; + color: #b4b472; } + +#main li { + color: green; + margin: 10px; + padding: 10px; + font-size: 18px; } + +//# sourceMappingURL=map-file-comment.css.map diff --git a/node_modules/convert-source-map/test/fixtures/map-file-comment-inline.css b/node_modules/convert-source-map/test/fixtures/map-file-comment-inline.css new file mode 100644 index 000000000..1e61b2417 --- /dev/null +++ b/node_modules/convert-source-map/test/fixtures/map-file-comment-inline.css @@ -0,0 +1,14 @@ +.header { + background: #444; + border: solid; + padding: 10px; + border-radius: 10px 5px 10px 5px; + color: #b4b472; } + +#main li { + color: green; + margin: 10px; + padding: 10px; + font-size: 18px; } + +/*# sourceMappingURL=data:application/json;base64,ewoidmVyc2lvbiI6ICIzIiwKIm1hcHBpbmdzIjogIkFBQUEsd0JBQXlCO0VBQ3ZCLFVBQVUsRUFBRSxJQUFJO0VBQ2hCLE1BQU0sRUFBRSxLQUFLO0VBQ2IsT0FBTyxFQUFFLElBQUk7RUFDYixhQUFhLEVBQUUsaUJBQWlCO0VBQ2hDLEtBQUssRUFBRSxPQUFrQjs7QUFHM0Isd0JBQXlCO0VBQ3ZCLE9BQU8sRUFBRSxJQUFJOztBQ1RmLGdCQUFpQjtFQUNmLFVBQVUsRUFBRSxJQUFJO0VBQ2hCLEtBQUssRUFBRSxNQUFNOztBQUdmLGtCQUFtQjtFQUNqQixNQUFNLEVBQUUsSUFBSTtFQUNaLE9BQU8sRUFBRSxJQUFJO0VBQ2IsVUFBVSxFQUFFLEtBQUs7RUFDakIsYUFBYSxFQUFFLEdBQUc7RUFDbEIsS0FBSyxFQUFFLEtBQUs7O0FBRWQsa0JBQW1CO0VBQ2pCLEtBQUssRUFBRSxLQUFLOztBQUdkLG1CQUFvQjtFQUNsQixLQUFLLEVBQUUsS0FBSztFQUNaLE1BQU0sRUFBRSxJQUFJO0VBQ1osT0FBTyxFQUFFLElBQUk7RUFDYixTQUFTLEVBQUUsSUFBSSIsCiJzb3VyY2VzIjogWyIuL2NsaWVudC9zYXNzL2NvcmUuc2NzcyIsIi4vY2xpZW50L3Nhc3MvbWFpbi5zY3NzIl0sCiJmaWxlIjogIm1hcC1maWxlLWNvbW1lbnQuY3NzIgp9 */ diff --git a/node_modules/convert-source-map/test/fixtures/map-file-comment.css b/node_modules/convert-source-map/test/fixtures/map-file-comment.css new file mode 100644 index 000000000..8b282680a --- /dev/null +++ b/node_modules/convert-source-map/test/fixtures/map-file-comment.css @@ -0,0 +1,14 @@ +.header { + background: #444; + border: solid; + padding: 10px; + border-radius: 10px 5px 10px 5px; + color: #b4b472; } + +#main li { + color: green; + margin: 10px; + padding: 10px; + font-size: 18px; } + +/*# sourceMappingURL=map-file-comment.css.map */ diff --git a/node_modules/convert-source-map/test/fixtures/map-file-comment.css.map b/node_modules/convert-source-map/test/fixtures/map-file-comment.css.map new file mode 100644 index 000000000..25950ea24 --- /dev/null +++ b/node_modules/convert-source-map/test/fixtures/map-file-comment.css.map @@ -0,0 +1,6 @@ +{ +"version": "3", +"mappings": "AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI", +"sources": ["./client/sass/core.scss","./client/sass/main.scss"], +"file": "map-file-comment.css" +} diff --git a/node_modules/convert-source-map/test/map-file-comment.js b/node_modules/convert-source-map/test/map-file-comment.js new file mode 100644 index 000000000..b41678777 --- /dev/null +++ b/node_modules/convert-source-map/test/map-file-comment.js @@ -0,0 +1,70 @@ +'use strict'; +/*jshint asi: true */ + +var test = require('tap').test + , rx = require('..') + , fs = require('fs') + , convert = require('..') + +test('\nresolving a "/*# sourceMappingURL=map-file-comment.css.map*/" style comment inside a given css content', function (t) { + var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment.css', 'utf8') + var conv = convert.fromMapFileSource(css, __dirname + '/fixtures'); + var sm = conv.toObject(); + + t.deepEqual( + sm.sources + , [ './client/sass/core.scss', + './client/sass/main.scss' ] + , 'resolves paths of original sources' + ) + + t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file') + t.equal( + sm.mappings + , 'AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI' + , 'includes mappings' + ) + t.end() +}) + +test('\nresolving a "//# sourceMappingURL=map-file-comment.css.map" style comment inside a given css content', function (t) { + var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment-double-slash.css', 'utf8') + var conv = convert.fromMapFileSource(css, __dirname + '/fixtures'); + var sm = conv.toObject(); + + t.deepEqual( + sm.sources + , [ './client/sass/core.scss', + './client/sass/main.scss' ] + , 'resolves paths of original sources' + ) + + t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file') + t.equal( + sm.mappings + , 'AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI' + , 'includes mappings' + ) + t.end() +}) + +test('\nresolving a /*# sourceMappingURL=data:application/json;base64,... */ style comment inside a given css content', function(t) { + var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment-inline.css', 'utf8') + var conv = convert.fromSource(css, __dirname + '/fixtures') + var sm = conv.toObject() + + t.deepEqual( + sm.sources + , [ './client/sass/core.scss', + './client/sass/main.scss' ] + , 'resolves paths of original sources' + ) + + t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file') + t.equal( + sm.mappings + , 'AAAA,wBAAyB;EACvB,UAAU,EAAE,IAAI;EAChB,MAAM,EAAE,KAAK;EACb,OAAO,EAAE,IAAI;EACb,aAAa,EAAE,iBAAiB;EAChC,KAAK,EAAE,OAAkB;;AAG3B,wBAAyB;EACvB,OAAO,EAAE,IAAI;;ACTf,gBAAiB;EACf,UAAU,EAAE,IAAI;EAChB,KAAK,EAAE,MAAM;;AAGf,kBAAmB;EACjB,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,UAAU,EAAE,KAAK;EACjB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,KAAK;;AAEd,kBAAmB;EACjB,KAAK,EAAE,KAAK;;AAGd,mBAAoB;EAClB,KAAK,EAAE,KAAK;EACZ,MAAM,EAAE,IAAI;EACZ,OAAO,EAAE,IAAI;EACb,SAAS,EAAE,IAAI' + , 'includes mappings' + ) + t.end() +}) |