Added wait into error tests.

This commit is contained in:
meri
2013-08-05 15:58:04 +02:00
parent 3765bb2926
commit 1ea0416adb
5 changed files with 31 additions and 4 deletions

View File

@@ -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'
}
}
},

View File

@@ -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;

View File

@@ -1,3 +1,4 @@
describe("less.js error tests", function() {
testLessErrorsInDocument();
});
testLessErrorsInDocument();
})

View File

@@ -0,0 +1,4 @@
var less = {};
less.strictUnits = true;
less.javascriptEnabled = false;

View File

@@ -0,0 +1,4 @@
describe("less.js javascript disabled error tests", function() {
testLessErrorsInDocument();
});