mirror of
https://github.com/konvajs/konva.git
synced 2026-01-18 19:51:21 +08:00
started working on context tracing. Added first context trace unit test
This commit is contained in:
@@ -1,19 +1,26 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Mocha Tests</title>
|
||||
<title>KineticJS Mocha Tests</title>
|
||||
<link rel="stylesheet" href="../node_modules/mocha/mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
|
||||
<!-- used for KineticJS container -->
|
||||
<div id="container"></div>
|
||||
|
||||
<script src="../node_modules/mocha/mocha.js"></script>
|
||||
<script src="../node_modules/chai/chai.js"></script>
|
||||
<script src="../dist/kinetic-dev.js"></script>
|
||||
<script>
|
||||
mocha.ui('tdd');
|
||||
var assert = chai.assert;
|
||||
|
||||
Kinetic.enableTrace = true;
|
||||
</script>
|
||||
<script src="unit/Util-test.js"></script>
|
||||
<script src="unit/Rect-test.js"></script>
|
||||
<script>
|
||||
if (window.mochaPhantomJS) { mochaPhantomJS.run(); }
|
||||
else { mocha.run(); }
|
||||
|
||||
41
test/unit/Rect-test.js
Normal file
41
test/unit/Rect-test.js
Normal file
@@ -0,0 +1,41 @@
|
||||
suite('Rect', function(){
|
||||
var util;
|
||||
|
||||
setup(function(){
|
||||
|
||||
});
|
||||
|
||||
suite('add rect to stage', function(){
|
||||
var stage = new Kinetic.Stage({
|
||||
container: 'container',
|
||||
width: 578,
|
||||
height: 200
|
||||
});
|
||||
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
var rect = new Kinetic.Rect({
|
||||
x: 100,
|
||||
y: 50,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'green',
|
||||
stroke: 'blue'
|
||||
});
|
||||
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
test('getters', function(){
|
||||
assert.equal(rect.getX(), 100);
|
||||
assert.equal(rect.getY(), 50);
|
||||
|
||||
});
|
||||
|
||||
test('context trace array', function() {
|
||||
var traceArr = layer.getContext().traceArr;
|
||||
console.log(traceArr)
|
||||
assert.equal(traceArr[0], 'clearRect(0,0,578,200)');
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user