feat: more testing

This commit is contained in:
Smigz 2024-03-15 12:12:11 -04:00
parent 685020dc94
commit 670dd0f480
6 changed files with 164 additions and 27 deletions

View file

@ -1,29 +1,27 @@
import { Ship } from "../src/components/ship";
import { Ship } from '../src/components/ship';
it('should have length, number of times hit, and if sunk', () => {
// Small ship
const _ship = new Ship(2)
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()
})
expect(_ship.isSunk()).toBeFalsy();
});
it('is sunk', () => {
const _ship = new Ship(2);
_ship.hits = 2;
expect(_ship.isSunk()).toBeTruthy()
})
expect(_ship.isSunk()).toBeTruthy();
});