mirror of
https://gitea.smigz.com/smiggiddy/odin-codeprojects.git
synced 2025-06-28 04:45:36 -04:00
Battleship (#16)
* project: testing * feat: updated testing configs * feat: ship class and test * feat: more testing * feat: gameboard logic/tests complete * feat: add player methods * feat: add main app * sync: pushing latest code to repo * feat: add some basic styling and stuff * feat: added UI logic * feat: basic game is finished * feat: add adjacent rules * feat: basic game complete
This commit is contained in:
parent
d899a773bd
commit
099e6b13e7
23 changed files with 10431 additions and 9218 deletions
27
battleship/tests/ship.test.js
Normal file
27
battleship/tests/ship.test.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
import { Ship } from '../src/components/ship';
|
||||
|
||||
it('should have length, number of times hit, and if sunk', () => {
|
||||
// Small ship
|
||||
const _ship = new Ship(2);
|
||||
expect(_ship).toEqual({
|
||||
length: 2,
|
||||
hits: 0,
|
||||
});
|
||||
});
|
||||
|
||||
it('if hit, hit count should increase', () => {
|
||||
const _ship = new Ship(2);
|
||||
_ship.hit();
|
||||
expect(_ship.hits).toBe(1);
|
||||
});
|
||||
|
||||
it('is not sunk', () => {
|
||||
const _ship = new Ship(2);
|
||||
expect(_ship.isSunk()).toBeFalsy();
|
||||
});
|
||||
|
||||
it('is sunk', () => {
|
||||
const _ship = new Ship(2);
|
||||
_ship.hits = 2;
|
||||
expect(_ship.isSunk()).toBeTruthy();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue