mirror of
https://github.com/less/less.js.git
synced 2026-05-01 03:00:22 -04:00
Added wait into error tests.
This commit is contained in:
@@ -154,6 +154,14 @@ module.exports = function(grunt) {
|
||||
specs: 'test/browser/runner-errors-spec.js',
|
||||
outfile: 'test/browser/test-runner-errors.html'
|
||||
}
|
||||
},
|
||||
noJsErrors: {
|
||||
src: ['test/less/no-js-errors/*.less'],
|
||||
options: {
|
||||
helpers: 'test/browser/runner-no-js-errors-options.js',
|
||||
specs: 'test/browser/runner-no-js-errors-spec.js',
|
||||
outfile: 'test/browser/test-runner-no-js-errors.html'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -56,6 +56,7 @@ var testSheet = function(sheet) {
|
||||
});
|
||||
};
|
||||
|
||||
//TODO: do it cleaner - the same way as in css
|
||||
function extractId(href) {
|
||||
return href.replace(/^[a-z-]+:\/+?[^\/]+/, '' ) // Remove protocol & domain
|
||||
.replace(/^\//, '' ) // Remove root /
|
||||
@@ -71,17 +72,26 @@ var testErrorSheet = function(sheet) {
|
||||
// id = sheet.id.replace(/^original-less:/, "less-error-message:"),
|
||||
errorHref = lessHref.replace(/.less$/, ".txt"),
|
||||
errorFile = loadFile(errorHref),
|
||||
actualErrorElement = document.getElementById(id),
|
||||
actualErrorElement,
|
||||
actualErrorMsg;
|
||||
|
||||
// Less.js sets 10ms timer in order to add error message on top of page.
|
||||
waitsFor(function() {
|
||||
actualErrorElement = document.getElementById(id);
|
||||
return actualErrorElement!==null;
|
||||
}, "failed to load expected outout", 70);
|
||||
|
||||
|
||||
describe("the error", function() {
|
||||
expect(actualErrorElement).not.toBe(null);
|
||||
});
|
||||
|
||||
actualErrorMsg = actualErrorElement.innerText
|
||||
runs(function() {
|
||||
actualErrorMsg = actualErrorElement.innerText
|
||||
.replace(/\n\d+/g, function(lineNo) { return lineNo + " "; })
|
||||
.replace(/\n\s*in /g, " in ")
|
||||
.replace("\n\n", "\n");
|
||||
});
|
||||
|
||||
waitsFor(function() {
|
||||
return errorFile.loaded;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
describe("less.js error tests", function() {
|
||||
testLessErrorsInDocument();
|
||||
});
|
||||
testLessErrorsInDocument();
|
||||
})
|
||||
|
||||
|
||||
4
test/browser/runner-no-js-errors-options.js
Normal file
4
test/browser/runner-no-js-errors-options.js
Normal file
@@ -0,0 +1,4 @@
|
||||
var less = {};
|
||||
|
||||
less.strictUnits = true;
|
||||
less.javascriptEnabled = false;
|
||||
4
test/browser/runner-no-js-errors-spec.js
Normal file
4
test/browser/runner-no-js-errors-spec.js
Normal file
@@ -0,0 +1,4 @@
|
||||
describe("less.js javascript disabled error tests", function() {
|
||||
testLessErrorsInDocument();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user