Add test cases for when the closest ships are on the edge
This commit is contained in:
parent
08df4187fb
commit
32119625b7
1 changed files with 12 additions and 0 deletions
|
|
@ -108,6 +108,18 @@ describe("The determineDirection function", () => {
|
|||
expect(determineDirection(b, p)).to.be.lessThan(0);
|
||||
});
|
||||
|
||||
it("should return negative when the closest ship is on the 0th index", () => {
|
||||
let b = [ "p2", null, "p1", null, null, "p3", null ];
|
||||
let p = b.findIndex(x => x == "p1");
|
||||
expect(determineDirection(b, p)).to.be.lessThan(0);
|
||||
});
|
||||
|
||||
it("should return negative when the closest ship is on the highest index", () => {
|
||||
let b = [ null, "p2", null, null, "p1", null, "p3" ];
|
||||
let p = b.findIndex(x => x == "p1");
|
||||
expect(determineDirection(b, p)).to.be.greaterThan(0);
|
||||
});
|
||||
|
||||
it("should return positive when the only other ship is at a higher index", () => {
|
||||
let b = [
|
||||
null, null, null, null, null,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue