mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Converted browser/browser tests into jasmine.
This commit is contained in:
@@ -41,11 +41,23 @@ var testSheet = function(sheet) {
|
||||
it(sheet.id + " should match the expected output", function() {
|
||||
var lessOutputId = sheet.id.replace("original-", ""),
|
||||
expectedOutputId = "expected-" + lessOutputId,
|
||||
lessOutput = document.getElementById(lessOutputId).innerText,
|
||||
lessOutputObj,
|
||||
lessOutput,
|
||||
expectedOutputHref = document.getElementById(expectedOutputId).href,
|
||||
expectedOutput = loadFile(expectedOutputHref);
|
||||
|
||||
// Browser spec generates less on the fly, so we need to loose control
|
||||
waitsFor(function() {
|
||||
lessOutputObj = document.getElementById(lessOutputId);
|
||||
// the type condition is necessary because of inline browser tests
|
||||
return lessOutputObj!==null && lessOutputObj.type==="text/css";
|
||||
}, "generation of " + lessOutputId + "", 700);
|
||||
|
||||
runs(function() {
|
||||
lessOutput = lessOutputObj.innerText;
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return expectedOutput.loaded;
|
||||
}, "failed to load expected outout", 10000);
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
@import "http://localhost:8081/browser/less/modify-this.css";
|
||||
@import "http://localhost:8081/browser/less/modify-again.css";
|
||||
@import "http://localhost:8081/test/browser/less/modify-this.css";
|
||||
|
||||
@import "http://localhost:8081/test/browser/less/modify-again.css";
|
||||
.modify {
|
||||
my-url: url("http://localhost:8081/browser/less/a.png");
|
||||
my-url: url("http://localhost:8081/test/browser/less/a.png");
|
||||
}
|
||||
.modify {
|
||||
my-url: url("http://localhost:8081/browser/less/b.png");
|
||||
my-url: url("http://localhost:8081/test/browser/less/b.png");
|
||||
}
|
||||
@font-face {
|
||||
src: url("/fonts/garamond-pro.ttf");
|
||||
src: local(Futura-Medium), url(http://localhost:8081/browser/less/fonts.svg#MyGeometricModern) format("svg");
|
||||
src: local(Futura-Medium), url(http://localhost:8081/test/browser/less/fonts.svg#MyGeometricModern) format("svg");
|
||||
}
|
||||
#shorthands {
|
||||
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
|
||||
}
|
||||
#misc {
|
||||
background-image: url(http://localhost:8081/browser/less/images/image.jpg);
|
||||
background-image: url(http://localhost:8081/test/browser/less/images/image.jpg);
|
||||
}
|
||||
#data-uri {
|
||||
background: url(data:image/png;charset=utf-8;base64,
|
||||
@@ -28,23 +29,23 @@
|
||||
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
|
||||
}
|
||||
.comma-delimited {
|
||||
background: url(http://localhost:8081/browser/less/bg.jpg) no-repeat, url(http://localhost:8081/browser/less/bg.png) repeat-x top left, url(http://localhost:8081/browser/less/bg);
|
||||
background: url(http://localhost:8081/test/browser/less/bg.jpg) no-repeat, url(http://localhost:8081/test/browser/less/bg.png) repeat-x top left, url(http://localhost:8081/test/browser/less/bg);
|
||||
}
|
||||
.values {
|
||||
url: url('http://localhost:8081/browser/less/Trebuchet');
|
||||
url: url('http://localhost:8081/test/browser/less/Trebuchet');
|
||||
}
|
||||
#data-uri {
|
||||
uri: url('http://localhost:8081/browser/less/../../data/image.jpg');
|
||||
uri: url('http://localhost:8081/test/browser/less/../../data/image.jpg');
|
||||
}
|
||||
#data-uri-guess {
|
||||
uri: url('http://localhost:8081/browser/less/../../data/image.jpg');
|
||||
uri: url('http://localhost:8081/test/browser/less/../../data/image.jpg');
|
||||
}
|
||||
#data-uri-ascii {
|
||||
uri-1: url('http://localhost:8081/browser/less/../../data/page.html');
|
||||
uri-2: url('http://localhost:8081/browser/less/../../data/page.html');
|
||||
uri-1: url('http://localhost:8081/test/browser/less/../../data/page.html');
|
||||
uri-2: url('http://localhost:8081/test/browser/less/../../data/page.html');
|
||||
}
|
||||
#data-uri-toobig {
|
||||
uri: url('http://localhost:8081/browser/less/../../data/data-uri-fail.png');
|
||||
uri: url('http://localhost:8081/test/browser/less/../../data/data-uri-fail.png');
|
||||
}
|
||||
#svg-functions {
|
||||
background-image: url('data:image/svg+xml,<?xml version="1.0" ?><svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="100%" height="100%" viewBox="0 0 1 1" preserveAspectRatio="none"><linearGradient id="gradient" gradientUnits="userSpaceOnUse" x1="0%" y1="0%" x2="0%" y2="100%"><stop offset="0%" stop-color="#000000"/><stop offset="100%" stop-color="#ffffff"/></linearGradient><rect x="0" y="0" width="1" height="1" fill="url(#gradient)" /></svg>');
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@import "imports/urls.less";
|
||||
@import "http://localhost:8081/browser/less/imports/urls2.less";
|
||||
@import "http://localhost:8081/test/browser/less/imports/urls2.less";
|
||||
@font-face {
|
||||
src: url("/fonts/garamond-pro.ttf");
|
||||
src: local(Futura-Medium),
|
||||
|
||||
40
test/browser/runner-browser-options.js
Normal file
40
test/browser/runner-browser-options.js
Normal file
@@ -0,0 +1,40 @@
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
12
test/browser/runner-browser-spec.js
Normal file
12
test/browser/runner-browser-spec.js
Normal file
@@ -0,0 +1,12 @@
|
||||
describe("less.js browser behaviour", function() {
|
||||
testLessEqualsInDocument();
|
||||
|
||||
it("has some log messages", function() {
|
||||
expect(logMessages.length).toBeGreaterThan(0);
|
||||
});
|
||||
|
||||
for (var i = 0; i < testFiles.length; i++) {
|
||||
var sheet = testSheets[i];
|
||||
testSheet(sheet);
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user