Permalink
Browse files

Extend the directional-condition test case

Try to hit more of the directions, to get better coverage.  This exposes that some of the directions don't work properly.  For instance the `[EasyStar.LEFT]` condition fails because `calculateDirection()` can never return `LEFT`.
  • Loading branch information...
sbj42 committed Apr 1, 2017
1 parent 38435e8 commit 734104edf000b9e40605736ee6995c03b74a2686
Showing with 10 additions and 5 deletions.
  1. +10 −5 test/easystartest.js
View
@@ -302,14 +302,19 @@ describe("EasyStar.js", function() {
[0, 0, 0],
];
easyStar.setGrid(grid);
easyStar.enableDiagonals();
easyStar.setAcceptableTiles([0]);
easyStar.setDirectionalCondition(1,1, [EasyStar.RIGHT, EasyStar.TOP_RIGHT]);
easyStar.setDirectionalCondition(1,2, [EasyStar.LEFT]);
easyStar.findPath(0, 0, 2, 0, function (path) {
easyStar.setDirectionalCondition(2, 1, [EasyStar.TOP]);
easyStar.setDirectionalCondition(1, 2, [EasyStar.TOP_RIGHT]);
easyStar.setDirectionalCondition(2, 2, [EasyStar.LEFT]);
easyStar.setDirectionalCondition(1, 1, [EasyStar.BOTTOM_RIGHT]);
easyStar.setDirectionalCondition(0, 1, [EasyStar.RIGHT]);
easyStar.setDirectionalCondition(0, 0, [EasyStar.BOTTOM]);
easyStar.findPath(2, 0, 0, 0, function (path) {
expect(path).not.toBeNull();
expect(path[3]).toEqual({ x: 1, y: 2})
expect(path.length).toEqual(7);
expect(path[3]).toEqual({ x: 2, y: 2})
done();
});

0 comments on commit 734104e

Please sign in to comment.