diff options
Diffstat (limited to 'ts/bun/__tests__')
-rw-r--r-- | ts/bun/__tests__/gameOfLife.test.ts | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ts/bun/__tests__/gameOfLife.test.ts b/ts/bun/__tests__/gameOfLife.test.ts new file mode 100644 index 0000000..1fef3de --- /dev/null +++ b/ts/bun/__tests__/gameOfLife.test.ts @@ -0,0 +1,27 @@ +import { step, countNeighbors } from '../index'; + +describe('Game of Life', () => { + test('countNeighbors counts the number of live neighbors', () => { + const grid = [ + [false, true, false], + [false, true, false], + [false, true, false] + ]; + expect(countNeighbors(grid, 1, 1)).toBe(2); + expect(countNeighbors(grid, 0, 0)).toBe(1); + }); + + test('step advances the game by one step', () => { + const initial = [ + [false, true, false], + [false, true, false], + [false, true, false] + ]; + const expected = [ + [false, true, false], + [false, true, false], + [false, true, false] + ]; + expect(step(initial)).toEqual(expected); + }); +}); \ No newline at end of file |