Skip to content

Commit

Permalink
small test unit improvements
Browse files Browse the repository at this point in the history
- added a rotate test for me.Line, which also validate the call to the constructor with a list of object (as opposed to a list of Vector)
- fix wrong url for the utils unit when running through a browser
  • Loading branch information
obiot committed Aug 3, 2018
1 parent ad8d39f commit 3c4b99a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tests/index.html
Expand Up @@ -49,6 +49,6 @@
<script type="text/javascript" src="tests/spec/bitmapfontdata-spec.js"></script>
<script type="text/javascript" src="tests/spec/input-spec.js"></script>
<script type="text/javascript" src="tests/spec/camera-spec.js"></script>
<script type="text/javascript" src="tests/spec/utils.js"></script>
<script type="text/javascript" src="tests/spec/utils-spec.js"></script>
</body>
</html>
17 changes: 15 additions & 2 deletions tests/spec/line-spec.js
Expand Up @@ -39,15 +39,27 @@ describe("Shape : me.Line", function () {
expect(line.containsPoint(14, 30)).toEqual(true);
});

it("contains the point (60, -28) after rotating the line by -90 degrees", function () {
line.rotate(-Math.PI / 2);
expect(line.points[1].x).toBeCloseTo(60, 3);
// value is 27.99999996 after rotation
expect(line.points[1].y).toBeCloseTo(-28, 3);
});

it("does not contain the point (60, 28) after rotating back", function () {
line.rotate(Math.PI / 2);
expect(line.containsPoint(60, 28)).toEqual(false);
});

it("contains the point (28, 60)", function () {
expect(line.containsPoint(28, 60)).toEqual(true);
});

it("does not contains the point (15, 30)", function () {
it("does not contain the point (15, 30)", function () {
expect(line.containsPoint(15, 30)).toEqual(false);
});

it("does not contains the point (29, 61)", function () {
it("does not contain the point (29, 61)", function () {
expect(line.containsPoint(29, 61)).toEqual(false);
});

Expand All @@ -66,4 +78,5 @@ describe("Shape : me.Line", function () {
expect(boundingRect.pos.equals({x: 0, y: 0})).toEqual(true);
});
});

});

0 comments on commit 3c4b99a

Please sign in to comment.