aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-03-03 00:15:45 +0100
committerUlrich-Matthias Schäfer <ulima.ums@googlemail.com>2015-03-03 00:15:45 +0100
commitcc9a4a372893d948900ce3fe83dd1324b153757d (patch)
tree5727d4a0291130e390281ac623f1bfad6a5453b0 /spec
parent2eff42ea62f1ff8301000b49eae54cc8c370ee66 (diff)
downloadsvg.js-cc9a4a372893d948900ce3fe83dd1324b153757d.tar.gz
svg.js-cc9a4a372893d948900ce3fe83dd1324b153757d.zip
Fixes #258, added few fx-specs
Diffstat (limited to 'spec')
-rwxr-xr-xspec/index.html1
-rw-r--r--spec/spec/fx.js88
2 files changed, 89 insertions, 0 deletions
diff --git a/spec/index.html b/spec/index.html
index 8896dd0..a40e8d2 100755
--- a/spec/index.html
+++ b/spec/index.html
@@ -61,6 +61,7 @@
<script type="text/javascript" src="spec/number.js"></script>
<script type="text/javascript" src="spec/array.js"></script>
<script type="text/javascript" src="spec/hyperlink.js"></script>
+<script type="text/javascript" src="spec/fx.js"></script>
<script type="text/javascript">
(function() {
diff --git a/spec/spec/fx.js b/spec/spec/fx.js
new file mode 100644
index 0000000..e1b15a2
--- /dev/null
+++ b/spec/spec/fx.js
@@ -0,0 +1,88 @@
+describe('FX', function() {
+ var rect, fx, flag1 = flag2 = false
+
+ beforeEach(function() {
+ rect = draw.rect(100,100).move(100,100)
+ fx = rect.animate(500)
+ flag1 = flag2 = false
+ })
+
+ it('creates an instance of SVG.FX', function() {
+ expect(fx instanceof SVG.FX).toBe(true)
+ })
+
+ it('animates the x/y-attr', function() {
+
+ runs(function(){
+ fx.move(200,200)
+
+ setTimeout(function(){
+ expect(rect.x()).toBeGreaterThan(100)
+ expect(rect.y()).toBeGreaterThan(100)
+ flag1 = true
+ }, 250)
+
+ setTimeout(function(){
+ expect(rect.x()).toBe(200)
+ expect(rect.y()).toBe(200)
+ flag2 = true
+ }, 600)
+ })
+
+ waitsFor(function() {
+ return flag1;
+ }, "x/y should be animated", 300);
+
+ waitsFor(function() {
+ return flag2;
+ }, "x/y should be animated", 700);
+
+ })
+
+ it('animates transformations / sets rotation-center', function() {
+
+ runs(function(){
+
+ fx.transform({
+ rotation: 30,
+ cx: 10,
+ cy: 10,
+ x: 100,
+ scaleX: 0.8,
+ skewX: 1.2
+ })
+
+ setTimeout(function(){
+ var trans = rect.transform()
+ expect(trans.rotation).toBeGreaterThan(0)
+ expect(trans.cx).toBe(10)
+ expect(trans.cy).toBe(10)
+ expect(trans.x).toBeGreaterThan(0)
+ expect(trans.scaleX).toBeLessThan(1)
+ expect(trans.skewX).toBeGreaterThan(0)
+ flag1 = true
+ }, 250)
+
+ setTimeout(function(){
+ var trans = rect.transform()
+ expect(trans.rotation).toBe(30)
+ expect(trans.cx).toBe(10)
+ expect(trans.cy).toBe(10)
+ expect(trans.x).toBe(100)
+ expect(trans.scaleX).toBe(0.8)
+ expect(trans.skewX).toBe(1.2)
+ flag2 = true
+ }, 600)
+ })
+
+ waitsFor(function() {
+ return flag1;
+ }, "transformation should be animated", 300);
+
+ waitsFor(function() {
+ return flag2;
+ }, "transformation should be animated", 700);
+
+ })
+
+}) \ No newline at end of file