Advertisement
ptownhero

TDD Criticisms + Advice Please!

Jun 22nd, 2022 (edited)
982
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 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!
  2.  
  3. // Right now I'm looking into describe to help structure my tests!
  4.  
  5. import { setup } from '../src/index.js';
  6.  
  7. describe.skip('shipFactory functionality', () => {
  8.     let ship = setup.shipFactory(1);
  9.     ship.position = [{x: 1, y: 1}];
  10.     ship.isHit({x: 1, y: 1});
  11.  
  12.     let ship2 = setup.shipFactory(3);
  13.     ship2.position = [{x: 1, y: 1}, {x: 2, y: 1}, {x: 3, y: 1}];
  14.    
  15.     // Ship Factory Function
  16.     test.skip('Returns a ship object', () => {
  17.         expect(setup.shipFactory()).toEqual({
  18.             length, damageTaken, position, isHit, isSunk
  19.         });
  20.     });
  21.    
  22.     // isHit method
  23.     test.skip('isHit will return true on actual hit', () => {
  24.         expect(ship.isHit({x: 1, y: 1})).toBe(true);
  25.     });
  26.    
  27.     // isSunk method
  28.     test.skip('isSunk will add a sunk = true property on sunken ship' , () => {
  29.         expect(ship.sunk).toBe(true);
  30.     });
  31.  
  32.     test.skip("isSunk will not change on a not sunk ship", () => {
  33.         expect(ship2.isSunk()).toBe(undefined);
  34.     })
  35.    
  36.     // damageTaken property
  37.     test.skip('ship.damageTaken should = 1', () => {
  38.         expect(ship.damageTaken).toBe(1);
  39.     });
  40. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement