runner-browser-options.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. var less = {
  2. logLevel: 4,
  3. errorReporting: 'console',
  4. javascriptEnabled: true,
  5. math: 'always'
  6. };
  7. // test inline less in style tags by grabbing an assortment of less files and doing `@import`s
  8. var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media', 'mixins'],
  9. testSheets = [];
  10. // setup style tags with less and link tags pointing to expected css output
  11. /**
  12. * @todo - generate the node_modules path for this file and in templates
  13. */
  14. var lessFolder = '../../node_modules/@less/test-data/less'
  15. var cssFolder = '../../node_modules/@less/test-data/css'
  16. for (var i = 0; i < testFiles.length; i++) {
  17. var file = testFiles[i],
  18. lessPath = lessFolder + '/_main/' + file + '.less',
  19. cssPath = cssFolder + '/_main/' + file + '.css',
  20. lessStyle = document.createElement('style'),
  21. cssLink = document.createElement('link'),
  22. lessText = '@import "' + lessPath + '";';
  23. lessStyle.type = 'text/less';
  24. lessStyle.id = file;
  25. lessStyle.href = file;
  26. if (lessStyle.styleSheet === undefined) {
  27. lessStyle.appendChild(document.createTextNode(lessText));
  28. }
  29. cssLink.rel = 'stylesheet';
  30. cssLink.type = 'text/css';
  31. cssLink.href = cssPath;
  32. cssLink.id = 'expected-' + file;
  33. var head = document.getElementsByTagName('head')[0];
  34. head.appendChild(lessStyle);
  35. if (lessStyle.styleSheet) {
  36. lessStyle.styleSheet.cssText = lessText;
  37. }
  38. head.appendChild(cssLink);
  39. testSheets[i] = lessStyle;
  40. }