mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Did legacy tests and working on errors.
This commit is contained in:
23
Gruntfile.js
23
Gruntfile.js
@@ -127,18 +127,36 @@ module.exports = function(grunt) {
|
||||
options: {
|
||||
keepRunner: true, //TODO meri: remove after it is done
|
||||
host: 'http://localhost:8081/',
|
||||
helpers: 'test/browser/common.js',
|
||||
vendor: 'test/browser/common.js',
|
||||
template: 'test/browser/test-runner-template.tmpl'
|
||||
},
|
||||
main: {
|
||||
//src is used to build list of less files to compile
|
||||
src: ['test/less/*.less', '!test/less/javascript.less', '!test/less/urls.less'],
|
||||
options: {
|
||||
specs: 'test/browser/runner-main.js',
|
||||
helpers: 'test/browser/runner-main-options.js',
|
||||
specs: 'test/browser/runner-main-spec.js',
|
||||
outfile: 'test/browser/test-runner-main.html'
|
||||
}
|
||||
},
|
||||
legacy: {
|
||||
src: ['test/less/legacy/*.less'],
|
||||
options: {
|
||||
helpers: 'test/browser/runner-legacy-options.js',
|
||||
specs: 'test/browser/runner-legacy-spec.js',
|
||||
outfile: 'test/browser/test-runner-legacy.html'
|
||||
}
|
||||
},
|
||||
errors: {
|
||||
src: ['test/less/errors/*.less', '!test/less/errors/javascript-error.less'],
|
||||
options: {
|
||||
helpers: 'test/browser/runner-errors-options.js',
|
||||
specs: 'test/browser/runner-errors-spec.js',
|
||||
outfile: 'test/browser/test-runner-errors.html'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
// Before running tests, clean out the results
|
||||
// of any previous tests. (this will need to be
|
||||
// setup based on configuration of browser tests.
|
||||
@@ -189,6 +207,7 @@ module.exports = function(grunt) {
|
||||
// Run all tests
|
||||
grunt.registerTask('browserTest', [
|
||||
'connect:server',
|
||||
'jasmine'
|
||||
]);
|
||||
|
||||
// Run all tests
|
||||
|
||||
@@ -1,7 +1,15 @@
|
||||
/*if not async then phantomjs fails to run the webserver and the test concurrently*/
|
||||
var less = { async: true, strictMath: true };
|
||||
|
||||
/* record log messages for testing */
|
||||
var logAllIds = function() {
|
||||
var allTags = document.head.getElementsByTagName('style');
|
||||
var ids = [];
|
||||
for (var tg = 0; tg< allTags.length; tg++) {
|
||||
var tag = allTags[tg];
|
||||
if (tag.id) {
|
||||
console.log(tag.id);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var logMessages = [],
|
||||
realConsoleLog = console.log;
|
||||
console.log = function(msg) {
|
||||
@@ -48,10 +56,19 @@ var testSheet = function(sheet) {
|
||||
});
|
||||
};
|
||||
|
||||
function extractId(href) {
|
||||
return href.replace(/^[a-z-]+:\/+?[^\/]+/, '' ) // 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 testErrorSheet = function(sheet) {
|
||||
it(sheet.id + " should match an error", function() {
|
||||
var lessHref = sheet.href,
|
||||
id = sheet.id.replace(/^original-less:/, "less-error-message:"),
|
||||
id = "less-error-message:"+extractId(lessHref),
|
||||
// id = sheet.id.replace(/^original-less:/, "less-error-message:"),
|
||||
errorHref = lessHref.replace(/.less$/, ".txt"),
|
||||
errorFile = loadFile(errorHref),
|
||||
actualErrorElement = document.getElementById(id),
|
||||
|
||||
3
test/browser/runner-errors-options.js
Normal file
3
test/browser/runner-errors-options.js
Normal file
@@ -0,0 +1,3 @@
|
||||
var less = {};
|
||||
less.strictUnits = true;
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
less.strictUnits = true;
|
||||
|
||||
describe("less.js error tests", function() {
|
||||
testLessErrorsInDocument();
|
||||
});
|
||||
});
|
||||
4
test/browser/runner-legacy-options.js
Normal file
4
test/browser/runner-legacy-options.js
Normal file
@@ -0,0 +1,4 @@
|
||||
var less = {};
|
||||
less.strictMath = false;
|
||||
less.strictUnits = false;
|
||||
|
||||
3
test/browser/runner-legacy-spec.js
Normal file
3
test/browser/runner-legacy-spec.js
Normal file
@@ -0,0 +1,3 @@
|
||||
describe("less.js legacy tests", function() {
|
||||
testLessEqualsInDocument();
|
||||
});
|
||||
13
test/browser/runner-main-options.js
Normal file
13
test/browser/runner-main-options.js
Normal file
@@ -0,0 +1,13 @@
|
||||
var less = {};
|
||||
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") }
|
||||
}
|
||||
};
|
||||
|
||||
3
test/browser/runner-main-spec.js
Normal file
3
test/browser/runner-main-spec.js
Normal file
@@ -0,0 +1,3 @@
|
||||
describe("less.js main tests", function() {
|
||||
testLessEqualsInDocument();
|
||||
});
|
||||
@@ -18,22 +18,22 @@ var generateScriptsTasgs = function(allScripts) {
|
||||
lessName = pathParts[pathParts.length-1],
|
||||
name = lessName.split('.')[0];
|
||||
%>
|
||||
<link id="original-less:test-less-<%=name%>" rel="stylesheet/less" type="text/css" href="<%=fullLessName%>">
|
||||
<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%>"><%
|
||||
});
|
||||
%>
|
||||
|
||||
<!-- grunt-contrib-jasmine css -->
|
||||
<!-- grunt-contrib-jasmine css -->
|
||||
<% css.forEach(function(style){ %>
|
||||
<link rel="stylesheet" type="text/css" href="<%= style %>">
|
||||
<% }) %>
|
||||
<!-- inital grunt-contrib-jasmine scripts -->
|
||||
<!-- inital grunt-contrib-jasmine scripts -->
|
||||
<% generateScriptsTasgs([].concat(scripts.polyfills, scripts.jasmine)); %>
|
||||
<!-- less.js testing -->
|
||||
<% generateScriptsTasgs(scripts.vendor);
|
||||
%> <script>var less = { async: false, strictMath: true };</script><script src="less.js"></script>
|
||||
<% generateScriptsTasgs([].concat(scripts.helpers, scripts.specs)); %>
|
||||
<!-- final grunt-contrib-jasmine scripts -->
|
||||
<!-- less.js testing -->
|
||||
<% generateScriptsTasgs([].concat(scripts.vendor, scripts.helpers));
|
||||
%> <script src="less.js"></script>
|
||||
<% generateScriptsTasgs(scripts.specs); %>
|
||||
<!-- final grunt-contrib-jasmine scripts -->
|
||||
<% generateScriptsTasgs([].concat(scripts.reporters, scripts.start)); %>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user