File: runner-browser-options.js

package info (click to toggle)
less.js 1.6.3~dfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 2,240 kB
  • sloc: sh: 128; makefile: 35; perl: 11
file content (42 lines) | stat: -rw-r--r-- 1,453 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
var less = {};

// There originally run inside describe method. However, since they have not
// been inside it, they run at jasmine compile time (not runtime). It all
// worked cause less.js was in async mode and custom phantom runner had
// different setup then grunt-contrib-jasmine. They have been created before
// less.js run, even as they have been defined in spec.

// test inline less in style tags by grabbing an assortment of less files and doing `@import`s
var testFiles = ['charsets', 'colors', 'comments', 'css-3', 'strings', 'media', 'mixins'],
    testSheets = [];

// setup style tags with less and link tags pointing to expected css output
for (var i = 0; i < testFiles.length; i++) {
  var file = testFiles[i],
      lessPath  = '/test/less/' + file + '.less',
      cssPath   = '/test/css/' + file + '.css',
      lessStyle = document.createElement('style'),
      cssLink   = document.createElement('link'),
      lessText  = '@import "' + lessPath + '";';

  lessStyle.type = 'text/less';
  lessStyle.id = file;
  lessStyle.href = file;

  if (lessStyle.styleSheet) {
    lessStyle.styleSheet.cssText = lessText;
  } else {
    lessStyle.innerHTML = lessText;
  }

  cssLink.rel = 'stylesheet';
  cssLink.type = 'text/css';
  cssLink.href = cssPath;
  cssLink.id = 'expected-' + file;

  var head = document.getElementsByTagName('head')[0];

  head.appendChild(lessStyle);
  head.appendChild(cssLink);
  testSheets[i] = lessStyle;
}