Skip to content

Commit fd2926b

Browse files
committed
Implement tests for PlacedSymbol, which fail because of lack of Item#strokeBounds and problems with PlacedSymbol#rotate.
1 parent 422b891 commit fd2926b

3 files changed

Lines changed: 28 additions & 0 deletions

File tree

test/index.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
<script type="text/javascript" src="../src/basic/Size.js"></script>
1515
<script type="text/javascript" src="../src/basic/Matrix.js"></script>
1616
<script type="text/javascript" src="../src/document/Doc.js"></script>
17+
<script type="text/javascript" src="../src/document/Symbol.js"></script>
1718
<script type="text/javascript" src="../src/item/Item.js"></script>
1819
<script type="text/javascript" src="../src/item/Group.js"></script>
1920
<script type="text/javascript" src="../src/item/Layer.js"></script>
21+
<script type="text/javascript" src="../src/item/PlacedSymbol.js"></script>
2022
<script type="text/javascript" src="../src/item/PathStyle.js"></script>
2123
<script type="text/javascript" src="../src/path/Segment.js"></script>
2224
<script type="text/javascript" src="../src/path/PathItem.js"></script>
@@ -45,6 +47,7 @@
4547
<script type="text/javascript" src="tests/Path_Drawing_Commands.js"></script>
4648
<script type="text/javascript" src="tests/Path_Bounds.js"></script>
4749
<script type="text/javascript" src="tests/PathStyle.js"></script>
50+
<script type="text/javascript" src="tests/PlacedSymbol.js"></script>
4851
</head>
4952
<body>
5053
<h1 id="qunit-header">QUnit Test Suite</h1>

test/tests/Path.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
module('Path');
22

33
test('path.currentSegment', function() {
4+
var doc = new Doc();
45
var path = new Path();
56
path.moveTo([50, 50]);
67
path.lineTo([100, 100]);

test/tests/PlacedSymbol.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
module('Placed Symbol');
2+
3+
test('placedSymbol bounds', function() {
4+
var doc = new Doc();
5+
var path = new Path.Circle([50, 50], 50);
6+
var symbol = new Symbol(path);
7+
var placedSymbol = new PlacedSymbol(symbol);
8+
9+
// These tests currently fail because we haven't implemented
10+
// Item#strokeBounds yet.
11+
compareRectangles(placedSymbol.bounds,
12+
new Rectangle(-50.5, -50.5, 101, 101),
13+
'PlacedSymbol initial bounds.');
14+
15+
placedSymbol.scale(0.5);
16+
compareRectangles(placedSymbol.bounds,
17+
{ x: -25.5, y: -25.5, width: 51, height: 51 },
18+
'Bounds after scale');
19+
20+
placedSymbol.rotate(40);
21+
compareRectangles(placedSymbol.bounds,
22+
{ x: -25.50049, y: -25.50049, width: 51.00098, height: 51.00098 },
23+
'Bounds after rotation');
24+
});

0 commit comments

Comments
 (0)