paper.js/test/tests/Size.js

47 lines
1.3 KiB
JavaScript
Raw Permalink Normal View History

2011-07-01 06:17:45 -04:00
/*
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
2011-07-01 06:17:45 -04:00
* http://paperjs.org/
*
* Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
* http://juerglehni.com/ & https://puckey.studio/
2011-07-01 06:17:45 -04:00
*
* Distributed under the MIT license. See LICENSE file for details.
*
* All rights reserved.
*/
QUnit.module('Size');
test('new Size(10, 20)', function() {
2014-08-16 13:24:54 -04:00
var size = new Size(10, 20);
equals(size.toString(), '{ width: 10, height: 20 }');
2011-02-07 13:28:09 -05:00
});
test('new Size([10, 20])', function() {
2014-08-16 13:24:54 -04:00
var size = new Size([10, 20]);
equals(size.toString(), '{ width: 10, height: 20 }');
2011-02-07 13:28:09 -05:00
});
test('new Size({width: 10, height: 20})', function() {
2014-08-16 13:24:54 -04:00
var size = new Size({width: 10, height: 20});
equals(size.toString(), '{ width: 10, height: 20 }');
2011-02-07 13:28:09 -05:00
});
test('new Size(new Point(10, 20))', function() {
2014-08-16 13:24:54 -04:00
var size = new Size(new Point(10, 20));
equals(size.toString(), '{ width: 10, height: 20 }');
2011-02-07 13:28:09 -05:00
});
test('new Size({ x: 10, y: 20})', function() {
2014-08-16 13:24:54 -04:00
var size = new Size({x: 10, y: 20});
equals(size.toString(), '{ width: 10, height: 20 }');
});
test('new Size("10, 20")', function() {
equals(new Size('10, 20'), new Size(10, 20));
equals(new Size('10,20'), new Size(10, 20));
equals(new Size('10 20'), new Size(10, 20));
// Make sure it's integer values from the string:
equals(new Size('10 20').add(10), new Size(20, 30));
});