Created
November 16, 2019 16:46
-
-
Save davidmatas/3661e29fdf5761a25b8d9b369643a006 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import should from 'should'; | |
import GameOfLife, { Cell } from '../../src/GameOfLife'; | |
// 1. Any live cell with fewer than two live neighbours dies, as if caused by underpopulation. | |
// 2. Any live cell with more than three live neighbours dies, as if by overcrowding. | |
// 3. Any live cell with two or three live neighbours lives on to the next generation. | |
// 4. Any dead cell with exactly three live neighbours becomes a live cell. | |
describe('GameOfLife', () => { | |
it('needs to be defined', () => { | |
const gameOfLife = new GameOfLife(); | |
should(gameOfLife).not.be.undefined() | |
}) | |
it('Any live cell with fewer than two live neighbours dies, as if caused by underpopulation', () => { | |
const cell = new Cell(1) | |
const cellStatus = cell.getNextStatus(1) | |
should(cellStatus).be.equal(0) | |
}) | |
it('Any live cell with more than three live neighbours dies, as if by overcrowding.', () => { | |
const cell = new Cell(1) | |
const cellStatus = cell.getNextStatus(4) | |
should(cellStatus).be.equal(0) | |
}) | |
it('Any live cell with two lives neighbours on to the next generation.', () => { | |
const cell = new Cell(1) | |
const cellStatus = cell.getNextStatus(2) | |
should(cellStatus).be.equal(1) | |
}) | |
it('Any live cell with three lives neighbours on to the next generation.', () => { | |
const cell = new Cell(1) | |
const cellStatus = cell.getNextStatus(3) | |
should(cellStatus).be.equal(1) | |
}) | |
it('Any dead cell with exactly three live neighbours becomes a live cell.', () => { | |
const cell = new Cell(0) | |
const cellStatus = cell.getNextStatus(3) | |
should(cellStatus).be.equal(1) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment