index.js 4.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. var lessTest = require('./less-test'),
  2. lessTester = lessTest(),
  3. path = require('path'),
  4. stylize = require('../lib/less-node/lessc-helper').stylize;
  5. console.log('\n' + stylize('Less', 'underline') + '\n');
  6. var testMap = [
  7. [{
  8. // TODO: Change this to rewriteUrls: 'all' once the relativeUrls option is removed
  9. relativeUrls: true,
  10. silent: true,
  11. javascriptEnabled: true
  12. }, '_main/'],
  13. [{}, 'namespacing/'],
  14. [{
  15. math: 'strict-legacy'
  16. }, 'math/strict-legacy/'],
  17. [{
  18. math: 'parens'
  19. }, 'math/strict/'],
  20. [{
  21. math: 'parens-division'
  22. }, 'math/parens-division/'],
  23. // Use legacy strictMath: true here to demonstrate it still works
  24. [{strictMath: true, strictUnits: true, javascriptEnabled: true}, '../errors/eval/',
  25. lessTester.testErrors, null],
  26. [{strictMath: true, strictUnits: true, javascriptEnabled: true}, '../errors/parse/',
  27. lessTester.testErrors, null],
  28. [{math: 'strict', strictUnits: true, javascriptEnabled: false}, 'no-js-errors/',
  29. lessTester.testErrors, null],
  30. [{math: 'strict', dumpLineNumbers: 'comments'}, 'debug/', null,
  31. function(name) { return name + '-comments'; }],
  32. [{math: 'strict', dumpLineNumbers: 'mediaquery'}, 'debug/', null,
  33. function(name) { return name + '-mediaquery'; }],
  34. [{math: 'strict', dumpLineNumbers: 'all'}, 'debug/', null,
  35. function(name) { return name + '-all'; }],
  36. // TODO: Change this to rewriteUrls: false once the relativeUrls option is removed
  37. [{math: 'strict', relativeUrls: false, rootpath: 'folder (1)/'}, 'static-urls/'],
  38. [{math: 'strict', compress: true}, 'compression/'],
  39. [{math: 0, strictUnits: true}, 'strict-units/'],
  40. [{}, 'legacy/'],
  41. [{math: 'strict', strictUnits: true, sourceMap: true, globalVars: true }, 'sourcemaps/',
  42. lessTester.testSourcemap, null, null,
  43. function(filename, type, baseFolder) {
  44. if (type === 'vars') {
  45. return path.join(baseFolder, filename) + '.json';
  46. }
  47. return path.join('test/sourcemaps', filename) + '.json';
  48. }],
  49. [{math: 'strict', strictUnits: true, globalVars: true }, '_main/import/json/',
  50. lessTester.testImports, null, true,
  51. function(filename, type, baseFolder) {
  52. return path.join(baseFolder, filename) + '.json';
  53. }],
  54. [{math: 'strict', strictUnits: true, sourceMap: {sourceMapFileInline: true}},
  55. 'sourcemaps-empty/', lessTester.testEmptySourcemap],
  56. [{math: 'strict', strictUnits: true, sourceMap: {disableSourcemapAnnotation: true}},
  57. 'sourcemaps-disable-annotation/', lessTester.testSourcemapWithoutUrlAnnotation],
  58. [{globalVars: true, banner: '/**\n * Test\n */\n'}, 'globalVars/',
  59. null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
  60. [{modifyVars: true}, 'modifyVars/',
  61. null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; }],
  62. [{urlArgs: '424242'}, 'url-args/'],
  63. [{rewriteUrls: 'all'}, 'rewrite-urls-all/'],
  64. [{rewriteUrls: 'local'}, 'rewrite-urls-local/'],
  65. [{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'all'}, 'rootpath-rewrite-urls-all/'],
  66. [{rootpath: 'http://example.com/assets/css/', rewriteUrls: 'local'}, 'rootpath-rewrite-urls-local/'],
  67. [{paths: ['data/', '_main/import/']}, 'include-path/'],
  68. [{paths: 'data/'}, 'include-path-string/'],
  69. [{plugin: 'test/plugins/postprocess/'}, 'postProcessorPlugin/'],
  70. [{plugin: 'test/plugins/preprocess/'}, 'preProcessorPlugin/'],
  71. [{plugin: 'test/plugins/visitor/'}, 'visitorPlugin/'],
  72. [{plugin: 'test/plugins/filemanager/'}, 'filemanagerPlugin/'],
  73. [{}, 'no-strict-math/'],
  74. [{}, '3rd-party/'],
  75. [{ processImports: false }, 'process-imports/']
  76. ];
  77. testMap.forEach(function(args) {
  78. lessTester.runTestSet.apply(lessTester, args)
  79. });
  80. lessTester.testSyncronous({syncImport: true}, '_main/import');
  81. lessTester.testSyncronous({syncImport: true}, '_main/plugin');
  82. lessTester.testSyncronous({syncImport: true}, 'math/strict-legacy/css');
  83. lessTester.testNoOptions();
  84. lessTester.testJSImport();
  85. lessTester.finished();