Project rename

This commit is contained in:
2019-03-24 08:28:57 +01:00
parent 1728e0e6e1
commit 7926230faf
7262 changed files with 0 additions and 0 deletions
+227
View File
@@ -0,0 +1,227 @@
/* Add js reporter for sauce */
jasmine.getEnv().addReporter(new jasmine.JSReporter2());
/* record log messages for testing */
var logMessages = [];
window.less = window.less || {};
var logLevel_debug = 4,
logLevel_info = 3,
logLevel_warn = 2,
logLevel_error = 1;
// The amount of logging in the javascript console.
// 3 - Debug, information and errors
// 2 - Information and errors
// 1 - Errors
// 0 - None
// Defaults to 2
less.loggers = [
{
debug: function(msg) {
if (less.options.logLevel >= logLevel_debug) {
logMessages.push(msg);
}
},
info: function(msg) {
if (less.options.logLevel >= logLevel_info) {
logMessages.push(msg);
}
},
warn: function(msg) {
if (less.options.logLevel >= logLevel_warn) {
logMessages.push(msg);
}
},
error: function(msg) {
if (less.options.logLevel >= logLevel_error) {
logMessages.push(msg);
}
}
}
];
var testLessEqualsInDocument = function () {
testLessInDocument(testSheet);
};
var testLessErrorsInDocument = function (isConsole) {
testLessInDocument(isConsole ? testErrorSheetConsole : testErrorSheet);
};
var testLessInDocument = function (testFunc) {
var links = document.getElementsByTagName('link'),
typePattern = /^text\/(x-)?less$/;
for (var i = 0; i < links.length; i++) {
if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
(links[i].type.match(typePattern)))) {
testFunc(links[i]);
}
}
};
var ieFormat = function(text) {
var styleNode = document.createElement('style');
styleNode.setAttribute('type', 'text/css');
var headNode = document.getElementsByTagName('head')[0];
headNode.appendChild(styleNode);
try {
if (styleNode.styleSheet) {
styleNode.styleSheet.cssText = text;
} else {
styleNode.innerText = text;
}
} catch (e) {
throw new Error("Couldn't reassign styleSheet.cssText.");
}
var transformedText = styleNode.styleSheet ? styleNode.styleSheet.cssText : styleNode.innerText;
headNode.removeChild(styleNode);
return transformedText;
};
var testSheet = function (sheet) {
it(sheet.id + " should match the expected output", function (done) {
var lessOutputId = sheet.id.replace("original-", ""),
expectedOutputId = "expected-" + lessOutputId,
lessOutputObj,
lessOutput,
expectedOutputHref = document.getElementById(expectedOutputId).href,
expectedOutput = loadFile(expectedOutputHref);
// Browser spec generates less on the fly, so we need to loose control
less.pageLoadFinished
.then(function () {
lessOutputObj = document.getElementById(lessOutputId);
lessOutput = lessOutputObj.styleSheet ? lessOutputObj.styleSheet.cssText :
(lessOutputObj.innerText || lessOutputObj.innerHTML);
expectedOutput
.then(function (text) {
if (window.navigator.userAgent.indexOf("MSIE") >= 0 ||
window.navigator.userAgent.indexOf("Trident/") >= 0) {
text = ieFormat(text);
}
expect(lessOutput).toEqual(text);
done();
});
});
});
};
//TODO: do it cleaner - the same way as in css
function extractId(href) {
return href.replace(/^[a-z-]+:\/+?[^\/]+/i, '') // Remove protocol & domain
.replace(/^\//, '') // Remove root /
.replace(/\.[a-zA-Z]+$/, '') // Remove simple extension
.replace(/[^\.\w-]+/g, '-') // Replace illegal characters
.replace(/\./g, ':'); // Replace dots with colons(for valid id)
}
var waitFor = function (waitFunc) {
return new Promise(function (resolve) {
var timeoutId = setInterval(function () {
if (waitFunc()) {
clearInterval(timeoutId);
resolve();
}
}, 5);
});
};
var testErrorSheet = function (sheet) {
it(sheet.id + " should match an error", function (done) {
var lessHref = sheet.href,
id = "less-error-message:" + extractId(lessHref),
errorHref = lessHref.replace(/.less$/, ".txt"),
errorFile = loadFile(errorHref),
actualErrorElement,
actualErrorMsg;
// Less.js sets 10ms timer in order to add error message on top of page.
waitFor(function () {
actualErrorElement = document.getElementById(id);
return actualErrorElement !== null;
}).then(function () {
var innerText = (actualErrorElement.innerHTML
.replace(/<h3>|<\/?p>|<a href="[^"]*">|<\/a>|<ul>|<\/?pre( class="?[^">]*"?)?>|<\/li>|<\/?label>/ig, "")
.replace(/<\/h3>/ig, " ")
.replace(/<li>|<\/ul>|<br>/ig, "\n"))
.replace(/&amp;/ig, "&")
// for IE8
.replace(/\r\n/g, "\n")
.replace(/\. \nin/, ". in");
actualErrorMsg = innerText
.replace(/\n\d+/g, function (lineNo) {
return lineNo + " ";
})
.replace(/\n\s*in /g, " in ")
.replace(/\n{2,}/g, "\n")
.replace(/\nStack Trace\n[\s\S]*/i, "")
.replace(/\n$/, "");
errorFile
.then(function (errorTxt) {
errorTxt = errorTxt
.replace(/\{path\}/g, "")
.replace(/\{pathrel\}/g, "")
.replace(/\{pathhref\}/g, "http://localhost:8081/test/less/errors/")
.replace(/\{404status\}/g, " (404)")
.replace(/\{node\}.*\{\/node\}/g, "")
.replace(/\n$/, "");
expect(actualErrorMsg).toEqual(errorTxt);
if (errorTxt == actualErrorMsg) {
actualErrorElement.style.display = "none";
}
done();
});
});
});
};
var testErrorSheetConsole = function (sheet) {
it(sheet.id + " should match an error", function (done) {
var lessHref = sheet.href,
id = sheet.id.replace(/^original-less:/, "less-error-message:"),
errorHref = lessHref.replace(/.less$/, ".txt"),
errorFile = loadFile(errorHref),
actualErrorElement = document.getElementById(id),
actualErrorMsg = logMessages[logMessages.length - 1]
.replace(/\nStack Trace\n[\s\S]*/, "");
describe("the error", function () {
expect(actualErrorElement).toBe(null);
});
errorFile
.then(function (errorTxt) {
errorTxt
.replace(/\{path\}/g, "")
.replace(/\{pathrel\}/g, "")
.replace(/\{pathhref\}/g, "http://localhost:8081/browser/less/")
.replace(/\{404status\}/g, " (404)")
.replace(/\{node\}.*\{\/node\}/g, "")
.trim();
expect(actualErrorMsg).toEqual(errorTxt);
done();
});
});
};
var loadFile = function (href) {
return new Promise(function (resolve, reject) {
var request = new XMLHttpRequest();
request.open('GET', href, true);
request.onreadystatechange = function () {
if (request.readyState == 4) {
resolve(request.responseText.replace(/\r/g, ""));
}
};
request.send(null);
});
};
jasmine.DEFAULT_TIMEOUT_INTERVAL = 90000;
@@ -0,0 +1,3 @@
.a {
prop: #000000;
}
@@ -0,0 +1,3 @@
.test-height {
height: image-height("../data/image.jpg");
}
@@ -0,0 +1,3 @@
.test-size {
size: image-size("../data/image.jpg");
}
@@ -0,0 +1,3 @@
.test-width {
width: image-width("../data/image.jpg");
}
@@ -0,0 +1,3 @@
.test {
color: red;
}
@@ -0,0 +1,4 @@
@import "modify-this.css";
.modify {
my-url: url("a.png");
}
@@ -0,0 +1,4 @@
@import "modify-again.css";
.modify {
my-url: url("b.png");
}
@@ -0,0 +1,3 @@
.testisimported {
color: gainsboro;
}
@@ -0,0 +1,8 @@
.testisimported {
color: gainsboro;
}
.test {
color1: #ff0000;
color2: #0000ff;
scalar: 10;
}
@@ -0,0 +1,3 @@
.gray-gradient {
background: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB2ZXJzaW9uPSIxLjEiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIHZpZXdCb3g9IjAgMCAxIDEiIHByZXNlcnZlQXNwZWN0UmF0aW89Im5vbmUiPjxsaW5lYXJHcmFkaWVudCBpZD0iZ3JhZGllbnQiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIiB4MT0iMCUiIHkxPSIwJSIgeDI9IjAlIiB5Mj0iMTAwJSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzk5OTk5OSIgc3RvcC1vcGFjaXR5PSIwIi8+PHN0b3Agb2Zmc2V0PSI2MCUiIHN0b3AtY29sb3I9IiM5OTk5OTkiIHN0b3Atb3BhY2l0eT0iMC4wNSIvPjxzdG9wIG9mZnNldD0iNzAlIiBzdG9wLWNvbG9yPSIjOTk5OTk5IiBzdG9wLW9wYWNpdHk9IjAuMSIvPjxzdG9wIG9mZnNldD0iNzMlIiBzdG9wLWNvbG9yPSIjOTk5OTk5IiBzdG9wLW9wYWNpdHk9IjAuMTUiLz48c3RvcCBvZmZzZXQ9Ijc1JSIgc3RvcC1jb2xvcj0iIzk5OTk5OSIgc3RvcC1vcGFjaXR5PSIwLjIiLz48c3RvcCBvZmZzZXQ9IjgwJSIgc3RvcC1jb2xvcj0iIzk5OTk5OSIgc3RvcC1vcGFjaXR5PSIwLjI1Ii8+PHN0b3Agb2Zmc2V0PSI4NSUiIHN0b3AtY29sb3I9IiM5OTk5OTkiIHN0b3Atb3BhY2l0eT0iMC4zIi8+PHN0b3Agb2Zmc2V0PSI4OCUiIHN0b3AtY29sb3I9IiM5OTk5OTkiIHN0b3Atb3BhY2l0eT0iMC4zNSIvPjxzdG9wIG9mZnNldD0iOTAlIiBzdG9wLWNvbG9yPSIjOTk5OTk5IiBzdG9wLW9wYWNpdHk9IjAuNCIvPjxzdG9wIG9mZnNldD0iOTUlIiBzdG9wLWNvbG9yPSIjOTk5OTk5IiBzdG9wLW9wYWNpdHk9IjAuNDUiLz48c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM5OTk5OTkiIHN0b3Atb3BhY2l0eT0iMC41Ii8+PC9saW5lYXJHcmFkaWVudD48cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWRpZW50KSIgLz48L3N2Zz4=');
}
@@ -0,0 +1,3 @@
.test {
color: #ffffff;
}
@@ -0,0 +1,36 @@
@import "http://localhost:8081/test/browser/less/imports/modify-this.css";
@import "http://localhost:8081/test/browser/less/imports/modify-again.css";
.modify {
my-url: url("http://localhost:8081/test/browser/less/imports/a.png");
}
.modify {
my-url: url("http://localhost:8081/test/browser/less/imports/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(http://localhost:8081/test/browser/less/relative-urls/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/test/browser/less/relative-urls/images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(http://localhost:8081/test/browser/less/relative-urls/bg.jpg) no-repeat, url(http://localhost:8081/test/browser/less/relative-urls/bg.png) repeat-x top left, url(http://localhost:8081/test/browser/less/relative-urls/bg);
}
.values {
url: url('http://localhost:8081/test/browser/less/relative-urls/Trebuchet');
}
@@ -0,0 +1,35 @@
@import "https://www.github.com/cloudhead/imports/modify-this.css";
@import "https://www.github.com/cloudhead/imports/modify-again.css";
.modify {
my-url: url("https://www.github.com/cloudhead/imports/a.png");
}
.modify {
my-url: url("https://www.github.com/cloudhead/imports/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(https://www.github.com/cloudhead/less.js/fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(https://www.github.com/cloudhead/less.js/images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(https://www.github.com/cloudhead/less.js/bg.jpg) no-repeat, url(https://www.github.com/cloudhead/less.js/bg.png) repeat-x top left, url(https://www.github.com/cloudhead/less.js/bg);
}
.values {
url: url('https://www.github.com/cloudhead/less.js/Trebuchet');
}
@@ -0,0 +1,35 @@
@import "https://localhost/modify-this.css";
@import "https://localhost/modify-again.css";
.modify {
my-url: url("https://localhost/a.png");
}
.modify {
my-url: url("https://localhost/b.png");
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(https://localhost/fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(https://localhost/images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(https://localhost/bg.jpg) no-repeat, url(https://localhost/bg.png) repeat-x top left, url(https://localhost/bg);
}
.values {
url: url('https://localhost/Trebuchet');
}
+57
View File
@@ -0,0 +1,57 @@
@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/test/browser/less/a.png");
}
.modify {
my-url: url("http://localhost:8081/test/browser/less/b.png");
}
.gray-gradient {
background: url('data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20width%3D%22100%25%22%20height%3D%22100%25%22%20viewBox%3D%220%200%201%201%22%20preserveAspectRatio%3D%22none%22%3E%3ClinearGradient%20id%3D%22gradient%22%20gradientUnits%3D%22userSpaceOnUse%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220%22%2F%3E%3Cstop%20offset%3D%2260%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.05%22%2F%3E%3Cstop%20offset%3D%2270%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.1%22%2F%3E%3Cstop%20offset%3D%2273%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.15%22%2F%3E%3Cstop%20offset%3D%2275%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.2%22%2F%3E%3Cstop%20offset%3D%2280%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.25%22%2F%3E%3Cstop%20offset%3D%2285%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.3%22%2F%3E%3Cstop%20offset%3D%2288%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.35%22%2F%3E%3Cstop%20offset%3D%2290%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.4%22%2F%3E%3Cstop%20offset%3D%2295%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.45%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23999999%22%20stop-opacity%3D%220.5%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23gradient)%22%20%2F%3E%3C%2Fsvg%3E');
}
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium), url(http://localhost:8081/test/browser/less/fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(http://localhost:8081/test/browser/less/images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
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/test/browser/less/Trebuchet');
}
#data-uri {
uri: url('http://localhost:8081/test/data/image.jpg');
}
#data-uri-guess {
uri: url('http://localhost:8081/test/data/image.jpg');
}
#data-uri-ascii {
uri-1: url('http://localhost:8081/test/data/page.html');
uri-2: url('http://localhost:8081/test/data/page.html');
}
#data-uri-toobig {
uri: url('http://localhost:8081/test/data/data-uri-fail.png');
}
#svg-functions {
background-image: url('data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20width%3D%22100%25%22%20height%3D%22100%25%22%20viewBox%3D%220%200%201%201%22%20preserveAspectRatio%3D%22none%22%3E%3ClinearGradient%20id%3D%22gradient%22%20gradientUnits%3D%22userSpaceOnUse%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23000000%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23gradient)%22%20%2F%3E%3C%2Fsvg%3E');
background-image: url('data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20width%3D%22100%25%22%20height%3D%22100%25%22%20viewBox%3D%220%200%201%201%22%20preserveAspectRatio%3D%22none%22%3E%3ClinearGradient%20id%3D%22gradient%22%20gradientUnits%3D%22userSpaceOnUse%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%220%25%22%20stop-color%3D%22%23000000%22%2F%3E%3Cstop%20offset%3D%223%25%22%20stop-color%3D%22%23ffa500%22%2F%3E%3Cstop%20offset%3D%22100%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23gradient)%22%20%2F%3E%3C%2Fsvg%3E');
background-image: url('data:image/svg+xml,%3C%3Fxml%20version%3D%221.0%22%20%3F%3E%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20version%3D%221.1%22%20width%3D%22100%25%22%20height%3D%22100%25%22%20viewBox%3D%220%200%201%201%22%20preserveAspectRatio%3D%22none%22%3E%3ClinearGradient%20id%3D%22gradient%22%20gradientUnits%3D%22userSpaceOnUse%22%20x1%3D%220%25%22%20y1%3D%220%25%22%20x2%3D%220%25%22%20y2%3D%22100%25%22%3E%3Cstop%20offset%3D%221%25%22%20stop-color%3D%22%23c4c4c4%22%2F%3E%3Cstop%20offset%3D%223%25%22%20stop-color%3D%22%23ffa500%22%2F%3E%3Cstop%20offset%3D%225%25%22%20stop-color%3D%22%23008000%22%2F%3E%3Cstop%20offset%3D%2295%25%22%20stop-color%3D%22%23ffffff%22%2F%3E%3C%2FlinearGradient%3E%3Crect%20x%3D%220%22%20y%3D%220%22%20width%3D%221%22%20height%3D%221%22%20fill%3D%22url(%23gradient)%22%20%2F%3E%3C%2Fsvg%3E');
}
@@ -0,0 +1,391 @@
/*
This file is part of the Jasmine JSReporter project from Ivan De Marino.
Copyright (C) 2011-2014 Ivan De Marino <http://ivandemarino.me>
Copyright (C) 2014 Alex Treppass <http://alextreppass.co.uk>
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the <organization> nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL IVAN DE MARINO BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
(function (jasmine) {
if (!jasmine) {
throw new Error("[Jasmine JSReporter] 'Jasmine' library not found");
}
// ------------------------------------------------------------------------
// Jasmine JSReporter for Jasmine 1.x
// ------------------------------------------------------------------------
/**
* Calculate elapsed time, in Seconds.
* @param startMs Start time in Milliseconds
* @param finishMs Finish time in Milliseconds
* @return Elapsed time in Seconds */
function elapsedSec (startMs, finishMs) {
return (finishMs - startMs) / 1000;
}
/**
* Round an amount to the given number of Digits.
* If no number of digits is given, than '2' is assumed.
* @param amount Amount to round
* @param numOfDecDigits Number of Digits to round to. Default value is '2'.
* @return Rounded amount */
function round (amount, numOfDecDigits) {
numOfDecDigits = numOfDecDigits || 2;
return Math.round(amount * Math.pow(10, numOfDecDigits)) / Math.pow(10, numOfDecDigits);
}
/**
* Create a new array which contains only the failed items.
* @param items Items which will be filtered
* @returns {Array} of failed items */
function failures (items) {
var fs = [], i, v;
for (i = 0; i < items.length; i += 1) {
v = items[i];
if (!v.passed_) {
fs.push(v);
}
}
return fs;
}
/**
* Collect information about a Suite, recursively, and return a JSON result.
* @param suite The Jasmine Suite to get data from
*/
function getSuiteData (suite) {
var suiteData = {
description : suite.description,
durationSec : 0,
specs: [],
suites: [],
passed: true
},
specs = suite.specs(),
suites = suite.suites(),
i, ilen;
// Loop over all the Suite's Specs
for (i = 0, ilen = specs.length; i < ilen; ++i) {
suiteData.specs[i] = {
description : specs[i].description,
durationSec : specs[i].durationSec,
passed : specs[i].results().passedCount === specs[i].results().totalCount,
skipped : specs[i].results().skipped,
passedCount : specs[i].results().passedCount,
failedCount : specs[i].results().failedCount,
totalCount : specs[i].results().totalCount,
failures: failures(specs[i].results().getItems())
};
suiteData.passed = !suiteData.specs[i].passed ? false : suiteData.passed;
suiteData.durationSec += suiteData.specs[i].durationSec;
}
// Loop over all the Suite's sub-Suites
for (i = 0, ilen = suites.length; i < ilen; ++i) {
suiteData.suites[i] = getSuiteData(suites[i]); //< recursive population
suiteData.passed = !suiteData.suites[i].passed ? false : suiteData.passed;
suiteData.durationSec += suiteData.suites[i].durationSec;
}
// Rounding duration numbers to 3 decimal digits
suiteData.durationSec = round(suiteData.durationSec, 4);
return suiteData;
}
var JSReporter = function () {
};
JSReporter.prototype = {
reportRunnerStarting: function (runner) {
// Nothing to do
},
reportSpecStarting: function (spec) {
// Start timing this spec
spec.startedAt = new Date();
},
reportSpecResults: function (spec) {
// Finish timing this spec and calculate duration/delta (in sec)
spec.finishedAt = new Date();
// If the spec was skipped, reportSpecStarting is never called and spec.startedAt is undefined
spec.durationSec = spec.startedAt ? elapsedSec(spec.startedAt.getTime(), spec.finishedAt.getTime()) : 0;
},
reportSuiteResults: function (suite) {
// Nothing to do
},
reportRunnerResults: function (runner) {
var suites = runner.suites(),
i, j, ilen;
// Attach results to the "jasmine" object to make those results easy to scrap/find
jasmine.runnerResults = {
suites: [],
durationSec : 0,
passed : true
};
// Loop over all the Suites
for (i = 0, ilen = suites.length, j = 0; i < ilen; ++i) {
if (suites[i].parentSuite === null) {
jasmine.runnerResults.suites[j] = getSuiteData(suites[i]);
// If 1 suite fails, the whole runner fails
jasmine.runnerResults.passed = !jasmine.runnerResults.suites[j].passed ? false : jasmine.runnerResults.passed;
// Add up all the durations
jasmine.runnerResults.durationSec += jasmine.runnerResults.suites[j].durationSec;
j++;
}
}
// Decorate the 'jasmine' object with getters
jasmine.getJSReport = function () {
if (jasmine.runnerResults) {
return jasmine.runnerResults;
}
return null;
};
jasmine.getJSReportAsString = function () {
return JSON.stringify(jasmine.getJSReport());
};
}
};
// export public
jasmine.JSReporter = JSReporter;
// ------------------------------------------------------------------------
// Jasmine JSReporter for Jasmine 2.0
// ------------------------------------------------------------------------
/*
Simple timer implementation
*/
var Timer = function () {};
Timer.prototype.start = function () {
this.startTime = new Date().getTime();
return this;
};
Timer.prototype.elapsed = function () {
if (this.startTime == null) {
return -1;
}
return new Date().getTime() - this.startTime;
};
/*
Utility methods
*/
var _extend = function (obj1, obj2) {
for (var prop in obj2) {
obj1[prop] = obj2[prop];
}
return obj1;
};
var _clone = function (obj) {
if (obj !== Object(obj)) {
return obj;
}
return _extend({}, obj);
};
jasmine.JSReporter2 = function () {
this.specs = {};
this.suites = {};
this.rootSuites = [];
this.suiteStack = [];
// export methods under jasmine namespace
jasmine.getJSReport = this.getJSReport;
jasmine.getJSReportAsString = this.getJSReportAsString;
};
var JSR = jasmine.JSReporter2.prototype;
// Reporter API methods
// --------------------
JSR.suiteStarted = function (suite) {
suite = this._cacheSuite(suite);
// build up suite tree as we go
suite.specs = [];
suite.suites = [];
suite.passed = true;
suite.parentId = this.suiteStack.slice(this.suiteStack.length - 1)[0];
if (suite.parentId) {
this.suites[suite.parentId].suites.push(suite);
} else {
this.rootSuites.push(suite.id);
}
this.suiteStack.push(suite.id);
suite.timer = new Timer().start();
};
JSR.suiteDone = function (suite) {
suite = this._cacheSuite(suite);
suite.duration = suite.timer.elapsed();
suite.durationSec = suite.duration / 1000;
this.suiteStack.pop();
// maintain parent suite state
var parent = this.suites[suite.parentId];
if (parent) {
parent.passed = parent.passed && suite.passed;
}
// keep report representation clean
delete suite.timer;
delete suite.id;
delete suite.parentId;
delete suite.fullName;
};
JSR.specStarted = function (spec) {
spec = this._cacheSpec(spec);
spec.timer = new Timer().start();
// build up suites->spec tree as we go
spec.suiteId = this.suiteStack.slice(this.suiteStack.length - 1)[0];
this.suites[spec.suiteId].specs.push(spec);
};
JSR.specDone = function (spec) {
spec = this._cacheSpec(spec);
spec.duration = spec.timer.elapsed();
spec.durationSec = spec.duration / 1000;
spec.skipped = spec.status === 'pending';
spec.passed = spec.skipped || spec.status === 'passed';
spec.totalCount = spec.passedExpectations.length + spec.failedExpectations.length;
spec.passedCount = spec.passedExpectations.length;
spec.failedCount = spec.failedExpectations.length;
spec.failures = [];
for (var i = 0, j = spec.failedExpectations.length; i < j; i++) {
var fail = spec.failedExpectations[i];
spec.failures.push({
type: 'expect',
expected: fail.expected,
passed: false,
message: fail.message,
matcherName: fail.matcherName,
trace: {
stack: fail.stack
}
});
}
// maintain parent suite state
var parent = this.suites[spec.suiteId];
if (spec.failed) {
parent.failingSpecs.push(spec);
}
parent.passed = parent.passed && spec.passed;
// keep report representation clean
delete spec.timer;
delete spec.totalExpectations;
delete spec.passedExpectations;
delete spec.suiteId;
delete spec.fullName;
delete spec.id;
delete spec.status;
delete spec.failedExpectations;
};
JSR.jasmineDone = function () {
this._buildReport();
};
JSR.getJSReport = function () {
if (jasmine.jsReport) {
return jasmine.jsReport;
}
};
JSR.getJSReportAsString = function () {
if (jasmine.jsReport) {
return JSON.stringify(jasmine.jsReport);
}
};
// Private methods
// ---------------
JSR._haveSpec = function (spec) {
return this.specs[spec.id] != null;
};
JSR._cacheSpec = function (spec) {
var existing = this.specs[spec.id];
if (existing == null) {
existing = this.specs[spec.id] = _clone(spec);
} else {
_extend(existing, spec);
}
return existing;
};
JSR._haveSuite = function (suite) {
return this.suites[suite.id] != null;
};
JSR._cacheSuite = function (suite) {
var existing = this.suites[suite.id];
if (existing == null) {
existing = this.suites[suite.id] = _clone(suite);
} else {
_extend(existing, suite);
}
return existing;
};
JSR._buildReport = function () {
var overallDuration = 0;
var overallPassed = true;
var overallSuites = [];
for (var i = 0, j = this.rootSuites.length; i < j; i++) {
var suite = this.suites[this.rootSuites[i]];
overallDuration += suite.duration;
overallPassed = overallPassed && suite.passed;
overallSuites.push(suite);
}
jasmine.jsReport = {
passed: overallPassed,
durationSec: overallDuration / 1000,
suites: overallSuites
};
};
})(jasmine);
File diff suppressed because one or more lines are too long
@@ -0,0 +1,3 @@
.a {
prop: (3 / #fff);
}
@@ -0,0 +1,2 @@
less: OperationError: Can't subtract or divide a color from a number in {pathhref}console-errors/test-error.less on line null, column 0:
1 prop: (3 / #fff);
@@ -0,0 +1,3 @@
.test-height{
height: image-height("../data/image.jpg")
}
@@ -0,0 +1,4 @@
RuntimeError: error evaluating function `image-height`: Image size functions are not supported in browser version of less in image-height-error.less on line 2, column 11:
1 .test-height{
2 height: image-height("../data/image.jpg")
3 }
@@ -0,0 +1,3 @@
.test-size{
size: image-size("../data/image.jpg")
}
@@ -0,0 +1,4 @@
RuntimeError: error evaluating function `image-size`: Image size functions are not supported in browser version of less in image-size-error.less on line 2, column 9:
1 .test-size{
2 size: image-size("../data/image.jpg")
3 }
@@ -0,0 +1,3 @@
.test-width{
width: image-width("../data/image.jpg")
}
@@ -0,0 +1,4 @@
RuntimeError: error evaluating function `image-width`: Image size functions are not supported in browser version of less in image-width-error.less on line 2, column 10:
1 .test-width{
2 width: image-width("../data/image.jpg")
3 }
@@ -0,0 +1,3 @@
.test {
color: @global-var;
}
@@ -0,0 +1,4 @@
@import "modify-this.css";
.modify {
my-url: url("a.png");
}
@@ -0,0 +1,4 @@
@import "modify-again.css";
.modify {
my-url: url("b.png");
}
@@ -0,0 +1,4 @@
@var2: blue;
.testisimported {
color: gainsboro;
}
@@ -0,0 +1,8 @@
@import "imports/simple2";
@var1: red;
@scale: 10;
.test {
color1: @var1;
color2: @var2;
scalar: @scale
}
@@ -0,0 +1,5 @@
@import "svg-gradient-mixin.less";
.gray-gradient {
.gradient-mixin(#999);
}
@@ -0,0 +1,15 @@
.gradient-mixin(@color) {
background: svg-gradient(to bottom,
fade(@color, 0%) 0%,
fade(@color, 5%) 60%,
fade(@color, 10%) 70%,
fade(@color, 15%) 73%,
fade(@color, 20%) 75%,
fade(@color, 25%) 80%,
fade(@color, 30%) 85%,
fade(@color, 35%) 88%,
fade(@color, 40%) 90%,
fade(@color, 45%) 95%,
fade(@color, 50%) 100%
);
}
@@ -0,0 +1,4 @@
@color: white;
.test {
color: @color;
}
@@ -0,0 +1,34 @@
@import ".././imports/urls.less";
@import "http://localhost:8081/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
background: url("#inline-svg");
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}
@@ -0,0 +1,33 @@
@import "../imports/urls.less";
@import "http://localhost:8081/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}
@@ -0,0 +1,33 @@
@import "../imports/urls.less";
@import "http://localhost:8081/test/browser/less/imports/urls2.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}
+65
View File
@@ -0,0 +1,65 @@
@import "imports/urls.less";
@import "http://localhost:8081/test/browser/less/imports/urls2.less";
@import "http://localhost:8081/test/browser/less/nested-gradient-with-svg-gradient/mixin-consumer.less";
@font-face {
src: url("/fonts/garamond-pro.ttf");
src: local(Futura-Medium),
url(fonts.svg#MyGeometricModern) format("svg");
not-a-comment: url(//z);
}
#shorthands {
background: url("http://www.lesscss.org/spec.html") no-repeat 0 4px;
}
#misc {
background-image: url(images/image.jpg);
}
#data-uri {
background: url(data:image/png;charset=utf-8;base64,
kiVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABlBMVEUAAAD/
k//+l2Z/dAAAAM0lEQVR4nGP4/5/h/1+G/58ZDrAz3D/McH8yw83NDDeNGe4U
kg9C9zwz3gVLMDA/A6P9/AFGGFyjOXZtQAAAAAElFTkSuQmCC);
background-image: url(data:image/x-png,f9difSSFIIGFIFJD1f982FSDKAA9==);
background-image: url(http://fonts.googleapis.com/css?family=\"Rokkitt\":\(400\),700);
}
#svg-data-uri {
background: transparent url('data:image/svg+xml, <svg version="1.1"><g></g></svg>');
}
.comma-delimited {
background: url(bg.jpg) no-repeat, url(bg.png) repeat-x top left, url(bg);
}
.values {
@a: 'Trebuchet';
url: url(@a);
}
#data-uri {
uri: data-uri('image/jpeg;base64', '../../data/image.jpg');
}
#data-uri-guess {
uri: data-uri('../../data/image.jpg');
}
#data-uri-ascii {
uri-1: data-uri('text/html', '../../data/page.html');
uri-2: data-uri('../../data/page.html');
}
#data-uri-toobig {
uri: data-uri('../../data/data-uri-fail.png');
}
#svg-functions {
@colorlist1: black, white;
background-image: svg-gradient(to bottom, @colorlist1);
background-image: svg-gradient(to bottom, black white);
background-image: svg-gradient(to bottom, black, orange 3%, white);
@colorlist2: black, orange 3%, white;
background-image: svg-gradient(to bottom, @colorlist2);
@green_5: green 5%;
@orange_percentage: 3%;
@orange_color: orange;
@colorlist3: (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%;
background-image: svg-gradient(to bottom,@colorlist3);
background-image: svg-gradient(to bottom, (mix(black, white) + #444) 1%, @orange_color @orange_percentage, ((@green_5)), white 95%);
}
@@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: "console",
plugins: [VisitorPlugin]};
@@ -0,0 +1,3 @@
describe("less.js Visitor Plugin", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,51 @@
var less = {logLevel: 4, errorReporting: "console"};
// 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 = [];
// IE 8-10 does not support less in style tags
if (window.navigator.userAgent.indexOf("MSIE") >= 0) {
testFiles.length = 0;
}
// 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 === undefined) {
lessStyle.appendChild(document.createTextNode(lessText));
}
cssLink.rel = 'stylesheet';
cssLink.type = 'text/css';
cssLink.href = cssPath;
cssLink.id = 'expected-' + file;
var head = document.getElementsByTagName('head')[0];
head.appendChild(lessStyle);
if (lessStyle.styleSheet) {
lessStyle.styleSheet.cssText = lessText;
}
head.appendChild(cssLink);
testSheets[i] = lessStyle;
}
@@ -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);
}
});
@@ -0,0 +1,5 @@
less.errorReporting = 'console';
describe("less.js error reporting console test", function() {
testLessErrorsInDocument(true);
});
@@ -0,0 +1,4 @@
var less = {
strictUnits: true,
strictMath: true,
logLevel: 4 };
@@ -0,0 +1,3 @@
describe("less.js error tests", function() {
testLessErrorsInDocument();
});
@@ -0,0 +1,4 @@
var less = {logLevel: 4,
errorReporting: "console",
plugins: [AddFilePlugin]
};
@@ -0,0 +1,3 @@
describe("less.js filemanager Plugin", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,7 @@
var less = {
logLevel: 4,
errorReporting: "console",
globalVars: {
"@global-var": "red"
}
};
@@ -0,0 +1,3 @@
describe("less.js global vars", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,5 @@
var less = {
logLevel: 4,
errorReporting: "console",
strictMath: false,
strictUnits: false };
@@ -0,0 +1,3 @@
describe("less.js legacy tests", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,18 @@
var less = {
logLevel: 4,
errorReporting: "console"
};
less.strictMath = true;
less.functions = {
add: function(a, b) {
return new(less.tree.Dimension)(a.value + b.value);
},
increment: function(a) {
return new(less.tree.Dimension)(a.value + 1);
},
_color: function(str) {
if (str.value === "evil red") {
return new(less.tree.Color)("600");
}
}
};
@@ -0,0 +1,7 @@
console.warn("start spec");
describe("less.js main tests", function() {
testLessEqualsInDocument();
it("the global environment", function() {
expect(window.require).toBe(undefined);
});
});
@@ -0,0 +1,5 @@
/* exported less */
var less = {
logLevel: 4,
errorReporting: "console"
};
@@ -0,0 +1,33 @@
var alreadyRun = false;
describe("less.js modify vars", function () {
beforeEach(function (done) {
// simulating "setUp" or "beforeAll" method
if (alreadyRun) {
done();
return;
}
alreadyRun = true;
less.pageLoadFinished
.then(function () {
less.modifyVars({
var1: "green",
var2: "purple",
scale: 20
}).then(function () {
done();
});
});
});
testLessEqualsInDocument();
it("Should log only 2 XHR requests", function (done) {
var xhrLogMessages = logMessages.filter(function (item) {
return (/XHR: Getting '/).test(item);
});
expect(xhrLogMessages.length).toEqual(2);
done();
});
});
@@ -0,0 +1,4 @@
var less = {logLevel: 4};
less.strictUnits = true;
less.javascriptEnabled = false;
@@ -0,0 +1,3 @@
describe("less.js javascript disabled error tests", function() {
testLessErrorsInDocument();
});
@@ -0,0 +1,5 @@
var less = {logLevel: 4,
errorReporting: "console"};
less.postProcessor = function(styles) {
return 'hr {height:50px;}\n' + styles;
};
@@ -0,0 +1,3 @@
describe("less.js postProcessor (deprecated)", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: "console",
plugins: [postProcessorPlugin]};
@@ -0,0 +1,3 @@
describe("less.js postProcessor Plugin", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: "console",
plugins: [preProcessorPlugin]};
@@ -0,0 +1,3 @@
describe("less.js preProcessor Plugin", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,3 @@
var less = {logLevel: 1,
errorReporting: "console"};
less.env = "production";
@@ -0,0 +1,5 @@
describe("less.js production behaviour", function() {
it("doesn't log any messages", function() {
expect(logMessages.length).toEqual(0);
});
});
@@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: "console"};
less.relativeUrls = true;
@@ -0,0 +1,3 @@
describe("less.js browser test - relative url's", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,3 @@
var less = {logLevel: 4,
errorReporting: "console"};
less.rootpath = "https://localhost/";
@@ -0,0 +1,4 @@
var less = {logLevel: 4,
errorReporting: "console"};
less.rootpath = "https://www.github.com/cloudhead/less.js/";
less.relativeUrls = true;
@@ -0,0 +1,3 @@
describe("less.js browser test - rootpath and relative url's", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,3 @@
describe("less.js browser test - rootpath url's", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,5 @@
var less = {
logLevel: 4,
errorReporting: "console",
strictMath: true,
strictUnits: true };
@@ -0,0 +1,3 @@
describe("less.js strict units tests", function() {
testLessEqualsInDocument();
});
@@ -0,0 +1,95 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Jasmine Spec Runner</title>
<!-- generate script tags for tests -->
<% var generateScriptTags = function(allScripts) { allScripts.forEach(function(script){ %>
<script src="<%= script %>"></script>
<% }); }; %>
<!-- generate script tags for tests -->
<% var toArray = function(scripts) {
%>[<%
scripts.forEach(function(scriptUrl, index){
%>"<%= scriptUrl %>"<%
if (index !== scripts.length -1) {
%>,<%
}
});
%>]<%
}; %>
<!-- for each test, generate CSS/LESS link tags -->
<% scripts.src.forEach(function(fullLessName) {
var pathParts = fullLessName.split('/');
var fullCssName = fullLessName.replace(/less/g, 'css');
var lessName = pathParts[pathParts.length - 1];
var name = lessName.split('.')[0]; %>
<!-- the tags to be generated -->
<link id="original-less:test-less-<%= name %>" title="test-less-<%= name %>" rel="stylesheet/less" type="text/css" href="<%= fullLessName %>">
<link id="expected-less:test-less-<%= name %>" rel="stylesheet" type="text/css" href="<%= fullCssName %>">
<% }); %>
<!-- generate grunt-contrib-jasmine link tags -->
<% css.forEach(function(style){ %>
<link rel="stylesheet" type="text/css" href="<%= style %>">
<% }) %>
<script>
function loadScript(url,callback){
var script = document.createElement('script');
if(document.documentMode === 8){
script.onreadystatechange = function(){
if (script.readyState === 'loaded'){
if (callback){callback()};
};
};
} else {
script.onload = function(){
if (callback){callback()};
};
};
script.src = url;
document.body.appendChild(script);
};
// allow sauce to query for the jasmine report
// because we have to load the page before starting the test, so the thing
// sauce queries for might not be setup yet
window.jasmine = { getJSReport: function() { } };
setTimeout(function() {
var jasmine = <% toArray([].concat(scripts.polyfills, scripts.jasmine, scripts.boot)) %>,
helpers = <% toArray(scripts.helpers) %>,
vendor = <% toArray(scripts.vendor) %>,
specs = <% toArray(scripts.specs) %>,
reporters = <% toArray([].concat(scripts.reporters)) %>,
allScripts = jasmine.concat(helpers).concat(vendor).concat(specs).concat(reporters);
function addNextScript() {
// for sauce, see above. Additional step needed between loading jasmine and loading
// the js reporter
if (!jasmine.getJSReport) {
jasmine.getJSReport = function() {};
}
if (allScripts.length) {
var scriptSrc = allScripts.shift();
loadScript(scriptSrc, addNextScript);
} else {
window.onload();
}
}
addNextScript();
},1000);
</script>
</head>
<body>
<!-- content -->
</body>
</html>