Browse files

added some tests for straigthen() by 45 degrees steps

  • Loading branch information...
1 parent 3f2ad4b commit 67cc070b9d49077d03cd668ae1a531434c1e7db9 @fadomire committed Mar 21, 2013
Showing with 48 additions and 0 deletions.
  1. +12 −0 test/unit/canvas.js
  2. +12 −0 test/unit/canvas_static.js
  3. +24 −0 test/unit/object.js
View
12 test/unit/canvas.js
@@ -225,6 +225,18 @@
rect.setAngle('100');
canvas.straightenObject(rect);
equal(rect.getAngle(), 90, 'angle should be coerced to 90 (from 100)');
+
+ rect.setAngle('0');
+ equal(canvas.straightenObject(rect, 45), canvas, 'should be chainable');
+ equal(rect.getAngle(), 0, 'angle should be coerced to 0 (from 10)');
+
+ rect.setAngle('60');
+ canvas.straightenObject(rect, 45);
+ equal(rect.getAngle(), 45, 'angle should be coerced to 45 (from 60)');
+
+ rect.setAngle('100');
+ canvas.straightenObject(rect, 45);
+ equal(rect.getAngle(), 90, 'angle should be coerced to 90 (from 100)');
});
test('toJSON', function() {
View
12 test/unit/canvas_static.js
@@ -191,6 +191,18 @@
rect.setAngle('100');
canvas.straightenObject(rect);
equal(rect.getAngle(), 90, 'angle should be coerced to 90 (from 100)');
+
+ rect.setAngle('0');
+ equal(canvas.straightenObject(rect, 45), canvas, 'should be chainable');
+ equal(rect.getAngle(), 0, 'angle should be coerced to 0 (from 10)');
+
+ rect.setAngle('60');
+ canvas.straightenObject(rect, 45);
+ equal(rect.getAngle(), 45, 'angle should be coerced to 45 (from 60)');
+
+ rect.setAngle('100');
+ canvas.straightenObject(rect, 45);
+ equal(rect.getAngle(), 90, 'angle should be coerced to 90 (from 100)');
});
test('toSVG without preamble', function() {
View
24 test/unit/object.js
@@ -598,6 +598,30 @@
object.setAngle(999);
object.straighten();
equal(object.get('angle'), 270);
+
+ object.setAngle(123.456);
+ object.straighten(45);
+ equal(object.get('angle'), 135);
+
+ object.setAngle(97.111);
+ object.straighten(45);
+ equal(object.get('angle'), 90);
+
+ object.setAngle(3.45);
+ object.straighten(45);
+ equal(object.get('angle'), 0);
+
+ object.setAngle(-157);
+ object.straighten(45);
+ equal(object.get('angle'), -135);
+
+ object.setAngle(159);
+ object.straighten(45);
+ equal(object.get('angle'), 180);
+
+ object.setAngle(999);
+ object.straighten(45);
+ equal(object.get('angle'), 270);
});
test('toGrayscale', function() {

0 comments on commit 67cc070

Please sign in to comment.