Board constructor
|
Board |
should contain a matrix of tiles
|
- |
should be initialized with an empty array for ships
|
- |
should be initialized with isSetUp as false
|
- |
should have an instance of Moves
|
- |
Board.setup
|
Board |
it should add ships at random positions if setup is called with no parameters
|
- |
Board.addShip
|
Board |
should be able to add a ship to the board if the position is valid
|
- |
should mark the appropriate tiles after a ship is added
|
- |
should return false if adding a ship will overlap an existing ship
|
- |
should increment the appropriate shipTypeCount
|
- |
should return false if the shipTypeCount is exceeded
|
- |
should have isSetUp set to true after all required ships are added
|
- |
should have the intial board saved to Moves after all required ships are added
|
- |
Board.attack
|
Board |
should correctly register an Island
|
- |
should correctly register a Hit
|
- |
should correctly register a Miss
|
- |
should correctly register a Already Attacked
|
- |
should correctly register a Sunk
|
- |
should correctly register a Win
|
- |
Board.addMove
|
Board |
should be called from Board.attack
|
- |
should be reset isRandom to false after it is called
|
- |
Board.isWon
|
Board |
should return true after all the ships are sunk
|
- |
Board.getSampleShipArray
|
Board |
should return an array of length = totalCount
|
- |
Game constructor
|
Game |
should create a new board and set it up
|
- |
Game.randomAvailablePosition
|
Game |
should return a position that is not attacked
|
- |
Game.availableNeighbors
|
Game |
should return neighboring positions that have not been attacked
|
- |
Game.play
|
Game |
should end in the game being won
|
- |
Moves constructor
|
Moves |
should throw if {board} is not an instance of Board
|
- |
Moves.addMove
|
Moves |
should add a value to the moves array
|
- |
Parameters
|
parameters |
should have a total ship count of 7
|
- |
should have a total of 5 ship types
|
- |
Ship Constructor
|
Ship |
should contain construct a ship if the position is valid
|
- |
should contain the correct shipType
|
- |
should contain a hit array of false values
|
- |
should throw an error if the shipTypeId is invalid
|
- |
should throw an error if the orientation is invalid
|
- |
should throw an error if the position is invalid
|
- |
Ship.hit
|
Ship |
should set the proper hit index
|
- |
Tile Constructor
|
Tile |
should create valid tiles when rows and columns are in range
|
- |
should throw if the row or column is out of range
|
- |
Tile.toString
|
Tile |
should return an "o" if the tile is not attacked
|
- |
should return an "x" if the tile is attacked
|
- |
Tile.toHtml
|
Tile |
should return a span with an "o" if the tile is not attacked
|
- |
should return a span with an "x" if the tile is attacked
|
- |
Utils
|
Utils |
isRowValid should return true for valid rows
|
- |
isRowValid should return false for invalid rows
|
- |
isValidShipPosition should return true for valid ship positions
|
- |