map-file-comment.js 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. 'use strict';
  2. /*jshint asi: true */
  3. var test = require('tap').test
  4. , rx = require('..')
  5. , fs = require('fs')
  6. , convert = require('..')
  7. test('\nresolving a "/*# sourceMappingURL=map-file-comment.css.map*/" style comment inside a given css content', function (t) {
  8. var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment.css', 'utf8')
  9. var conv = convert.fromMapFileSource(css, __dirname + '/fixtures');
  10. var sm = conv.toObject();
  11. t.deepEqual(
  12. sm.sources
  13. , [ './client/sass/core.scss',
  14. './client/sass/main.scss' ]
  15. , 'resolves paths of original sources'
  16. )
  17. t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file')
  18. t.equal(
  19. sm.mappings
  20. , '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'
  21. , 'includes mappings'
  22. )
  23. t.end()
  24. })
  25. test('\nresolving a "//# sourceMappingURL=map-file-comment.css.map" style comment inside a given css content', function (t) {
  26. var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment-double-slash.css', 'utf8')
  27. var conv = convert.fromMapFileSource(css, __dirname + '/fixtures');
  28. var sm = conv.toObject();
  29. t.deepEqual(
  30. sm.sources
  31. , [ './client/sass/core.scss',
  32. './client/sass/main.scss' ]
  33. , 'resolves paths of original sources'
  34. )
  35. t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file')
  36. t.equal(
  37. sm.mappings
  38. , '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'
  39. , 'includes mappings'
  40. )
  41. t.end()
  42. })
  43. test('\nresolving a /*# sourceMappingURL=data:application/json;base64,... */ style comment inside a given css content', function(t) {
  44. var css = fs.readFileSync(__dirname + '/fixtures/map-file-comment-inline.css', 'utf8')
  45. var conv = convert.fromSource(css, __dirname + '/fixtures')
  46. var sm = conv.toObject()
  47. t.deepEqual(
  48. sm.sources
  49. , [ './client/sass/core.scss',
  50. './client/sass/main.scss' ]
  51. , 'resolves paths of original sources'
  52. )
  53. t.equal(sm.file, 'map-file-comment.css', 'includes filename of generated file')
  54. t.equal(
  55. sm.mappings
  56. , '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'
  57. , 'includes mappings'
  58. )
  59. t.end()
  60. })