2013-09-08 14:42:11 +08:00
|
|
|
mocha.ui('tdd');
|
|
|
|
var assert = chai.assert,
|
2013-09-30 22:52:13 +08:00
|
|
|
kineticContainer = document.getElementById('kinetic-container'),
|
|
|
|
origAssertEqual = assert.equal,
|
|
|
|
origAssert = assert,
|
|
|
|
origNotEqual = assert.notEqual,
|
|
|
|
assertionCount = 0,
|
|
|
|
assertions = document.createElement('em');
|
|
|
|
|
|
|
|
function init() {
|
|
|
|
// assert extenders so that we can count assertions
|
|
|
|
assert = function() {
|
|
|
|
origAssert.apply(this, arguments);
|
|
|
|
assertions.innerHTML = ++assertionCount;
|
|
|
|
};
|
|
|
|
assert.equal = function() {
|
|
|
|
origAssertEqual.apply(this, arguments);
|
|
|
|
assertions.innerHTML = ++assertionCount;
|
|
|
|
};
|
|
|
|
assert.notEqual = function() {
|
|
|
|
origNotEqual.apply(this, arguments);
|
|
|
|
assertions.innerHTML = ++assertionCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
window.onload = function() {
|
|
|
|
var mochaStats = document.getElementById('mocha-stats');
|
|
|
|
|
|
|
|
if (mochaStats) {
|
|
|
|
var li = document.createElement('li');
|
|
|
|
var anchor = document.createElement('a');
|
|
|
|
|
|
|
|
anchor.href = '#';
|
|
|
|
anchor.innerHTML = 'assertions:';
|
|
|
|
assertions.innerHTML = 0;
|
|
|
|
|
|
|
|
li.appendChild(anchor);
|
|
|
|
li.appendChild(assertions);
|
|
|
|
mochaStats.appendChild(li);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2013-09-08 14:42:11 +08:00
|
|
|
|
|
|
|
Kinetic.enableTrace = true;
|
2013-11-03 14:48:39 +08:00
|
|
|
|
2013-09-08 14:42:11 +08:00
|
|
|
|
2013-09-09 12:36:54 +08:00
|
|
|
function addStage() {
|
2013-09-08 14:42:11 +08:00
|
|
|
var container = document.createElement('div'),
|
|
|
|
stage = new Kinetic.Stage({
|
|
|
|
container: container,
|
|
|
|
width: 578,
|
|
|
|
height: 200
|
|
|
|
});
|
|
|
|
|
|
|
|
kineticContainer.appendChild(container);
|
|
|
|
|
|
|
|
return stage;
|
|
|
|
}
|
|
|
|
|
2013-09-09 12:36:54 +08:00
|
|
|
function addContainer() {
|
|
|
|
var container = document.createElement('div');
|
|
|
|
|
|
|
|
kineticContainer.appendChild(container);
|
|
|
|
|
|
|
|
return container;
|
|
|
|
}
|
|
|
|
|
2013-09-08 14:42:11 +08:00
|
|
|
function showHit(layer) {
|
|
|
|
var canvas = layer.hitCanvas._canvas;
|
|
|
|
canvas.style.position = 'relative';
|
|
|
|
|
|
|
|
kineticContainer.appendChild(canvas);
|
|
|
|
}
|
|
|
|
|
|
|
|
beforeEach(function(){
|
|
|
|
var title = document.createElement('h2'),
|
|
|
|
test = this.currentTest;
|
|
|
|
|
|
|
|
title.innerHTML = test.parent.title + ' - ' + test.title;
|
|
|
|
title.className = 'kinetic-title';
|
|
|
|
kineticContainer.appendChild(title);
|
2013-09-26 14:25:59 +08:00
|
|
|
|
|
|
|
// resets
|
|
|
|
Kinetic.inDblClickWindow = false;
|
|
|
|
Kinetic.DD.isDragging = false;
|
|
|
|
Kinetic.DD.node = undefined;
|
2013-09-30 22:52:13 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
init();
|