index.js 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. var lessTest = require("./less-test"),
  2. lessTester = lessTest(),
  3. path = require("path"),
  4. stylize = require('../lib/less-node/lessc-helper').stylize;
  5. function getErrorPathReplacementFunction(dir) {
  6. return function(input, baseDir) {
  7. return input.replace(/\{path\}/g, path.join(process.cwd(), baseDir, dir + "/"))
  8. .replace(/\{node\}/g, "")
  9. .replace(/\{\/node\}/g, "")
  10. .replace(/\{pathrel\}/g, path.join(baseDir, dir + "/"))
  11. .replace(/\{pathhref\}/g, "")
  12. .replace(/\{404status\}/g, "")
  13. .replace(/\r\n/g, '\n');
  14. };
  15. }
  16. console.log("\n" + stylize("Less", 'underline') + "\n");
  17. lessTester.prepBomTest();
  18. lessTester.runTestSet({strictMath: true, relativeUrls: true, silent: true});
  19. lessTester.runTestSet({strictMath: true, strictUnits: true}, "errors/",
  20. lessTester.testErrors, null, getErrorPathReplacementFunction("errors"));
  21. lessTester.runTestSet({strictMath: true, strictUnits: true, javascriptEnabled: false}, "no-js-errors/",
  22. lessTester.testErrors, null, getErrorPathReplacementFunction("no-js-errors"));
  23. lessTester.runTestSet({strictMath: true, dumpLineNumbers: 'comments'}, "debug/", null,
  24. function(name) { return name + '-comments'; });
  25. lessTester.runTestSet({strictMath: true, dumpLineNumbers: 'mediaquery'}, "debug/", null,
  26. function(name) { return name + '-mediaquery'; });
  27. lessTester.runTestSet({strictMath: true, dumpLineNumbers: 'all'}, "debug/", null,
  28. function(name) { return name + '-all'; });
  29. lessTester.runTestSet({strictMath: true, relativeUrls: false, rootpath: "folder (1)/"}, "static-urls/");
  30. lessTester.runTestSet({strictMath: true, compress: true}, "compression/");
  31. lessTester.runTestSet({strictMath: true, strictUnits: true}, "strict-units/");
  32. lessTester.runTestSet({}, "legacy/");
  33. lessTester.runTestSet({strictMath: true, strictUnits: true, sourceMap: true, globalVars: true }, "sourcemaps/",
  34. lessTester.testSourcemap, null, null,
  35. function(filename, type, baseFolder) {
  36. if (type === "vars") {
  37. return path.join(baseFolder, filename) + '.json';
  38. }
  39. return path.join('test/sourcemaps', filename) + '.json';
  40. });
  41. lessTester.runTestSet({strictMath: true, strictUnits: true, sourceMap: {sourceMapFileInline: true}}, "sourcemaps-empty/", lessTester.testEmptySourcemap);
  42. lessTester.runTestSet({globalVars: true, banner: "/**\n * Test\n */\n"}, "globalVars/",
  43. null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; });
  44. lessTester.runTestSet({modifyVars: true}, "modifyVars/",
  45. null, null, null, function(name, type, baseFolder) { return path.join(baseFolder, name) + '.json'; });
  46. lessTester.runTestSet({urlArgs: '424242'}, "url-args/");
  47. lessTester.runTestSet({paths: ['test/data/', 'test/less/import/']}, "include-path/");
  48. lessTester.runTestSet({paths: 'test/data/'}, "include-path-string/");
  49. lessTester.runTestSet({plugin: 'test/plugins/postprocess/'}, "postProcessorPlugin/");
  50. lessTester.runTestSet({plugin: 'test/plugins/preprocess/'}, "preProcessorPlugin/");
  51. lessTester.runTestSet({plugin: 'test/plugins/visitor/'}, "visitorPlugin/");
  52. lessTester.runTestSet({plugin: 'test/plugins/filemanager/'}, "filemanagerPlugin/");
  53. lessTester.runTestSet({}, "no-strict-math/");
  54. lessTester.testSyncronous({syncImport: true}, "import");
  55. lessTester.testSyncronous({syncImport: true}, "css");
  56. lessTester.testNoOptions();
  57. lessTester.finished();