Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I'm really really new to using TDD and Jest, are there any criticisms you guys see in my current test.js file to help cut off bad habits early? I'll take any advice too to build better tests!
- // Right now I'm looking into describe to help structure my tests!
- import { setup } from '../src/index.js';
- describe.skip('shipFactory functionality', () => {
- let ship = setup.shipFactory(1);
- ship.position = [{x: 1, y: 1}];
- ship.isHit({x: 1, y: 1});
- let ship2 = setup.shipFactory(3);
- ship2.position = [{x: 1, y: 1}, {x: 2, y: 1}, {x: 3, y: 1}];
- // Ship Factory Function
- test.skip('Returns a ship object', () => {
- expect(setup.shipFactory()).toEqual({
- length, damageTaken, position, isHit, isSunk
- });
- });
- // isHit method
- test.skip('isHit will return true on actual hit', () => {
- expect(ship.isHit({x: 1, y: 1})).toBe(true);
- });
- // isSunk method
- test.skip('isSunk will add a sunk = true property on sunken ship' , () => {
- expect(ship.sunk).toBe(true);
- });
- test.skip("isSunk will not change on a not sunk ship", () => {
- expect(ship2.isSunk()).toBe(undefined);
- })
- // damageTaken property
- test.skip('ship.damageTaken should = 1', () => {
- expect(ship.damageTaken).toBe(1);
- });
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement