mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 17:21:36 +08:00
added scrollbar support for container DOM, structured the unittests a bit better, and did some minor refactoring
This commit is contained in:
50
tests/js/Test.js
Normal file
50
tests/js/Test.js
Normal file
@@ -0,0 +1,50 @@
|
||||
function test(condition, message) {
|
||||
if(!condition) {
|
||||
throw new Error(message);
|
||||
}
|
||||
}
|
||||
function log(message) {
|
||||
console.log("LOG: " + message);
|
||||
}
|
||||
/**
|
||||
* Test constructor
|
||||
*/
|
||||
function Test() {
|
||||
this.testOnly = "";
|
||||
this.counter = 0;
|
||||
}
|
||||
/**
|
||||
* Test methods
|
||||
*/
|
||||
Test.prototype = {
|
||||
addTestContainer: function(key) {
|
||||
var row = document.createElement('div');
|
||||
var container = document.createElement('div');
|
||||
var testMessage = document.createElement('p');
|
||||
|
||||
container.id = key;
|
||||
|
||||
document.body.appendChild(testMessage);
|
||||
row.appendChild(container);
|
||||
row.className = "row";
|
||||
document.body.appendChild(row);
|
||||
|
||||
return {
|
||||
testMessage: testMessage
|
||||
};
|
||||
},
|
||||
run: function() {
|
||||
var tests = this.tests;
|
||||
|
||||
for(var key in tests) {
|
||||
if(!this.testOnly || (this.testOnly && this.testOnly == key)) {
|
||||
var obj = this.addTestContainer(key);
|
||||
this.counter++;
|
||||
console.log(this.counter + ") " + key);
|
||||
tests[key](key);
|
||||
obj.testMessage.innerHTML = this.counter + ") " + key + ': PASSED';
|
||||
obj.testMessage.setAttribute("class", "green");
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user