mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-06-28 21:05:36 -04:00
feat: gameboard logic/tests complete
This commit is contained in:
parent
670dd0f480
commit
904c4901da
2 changed files with 64 additions and 7 deletions
|
@ -46,7 +46,32 @@ it('should contain unique random coordinates for each ship', () => {
|
|||
duplicates = true;
|
||||
}
|
||||
}
|
||||
console.log(ship.coordinates);
|
||||
});
|
||||
expect(duplicates).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should show a ship was hit and increase the hit count', () => {
|
||||
let attacks = [8, 5];
|
||||
gb.ships[0].coordinates = [[8, 5]];
|
||||
gb.receiveAttack(attacks);
|
||||
expect(gb.ships[0].hits).toBe(1);
|
||||
});
|
||||
|
||||
it('should report if a ship is sunk', () => {
|
||||
gb.ships[0].length = 1;
|
||||
expect(gb.ships[0].isSunk()).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should track hits and misses', () => {
|
||||
expect(gb.scoreboard.hits.size).toBe(1);
|
||||
expect(gb.scoreboard.misses.size).toBe(0);
|
||||
|
||||
gb.receiveAttack([-1, -1]);
|
||||
expect(gb.scoreboard.misses.size).toBe(1);
|
||||
});
|
||||
|
||||
it('should have a sunk count of 1 and only four ships now', () => {
|
||||
gb.shipStatus();
|
||||
expect(gb.ships).toHaveLength(4);
|
||||
expect(gb.sunkShipCount).toBe(1);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue