From 4715baef25b39d2614b1d0cc67d8bcff5676b6ce Mon Sep 17 00:00:00 2001 From: sanine Date: Sat, 11 Nov 2023 15:48:28 -0600 Subject: add setup_board --- src/simulation/game.test.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/simulation/game.test.js (limited to 'src/simulation/game.test.js') diff --git a/src/simulation/game.test.js b/src/simulation/game.test.js new file mode 100644 index 0000000..ac65618 --- /dev/null +++ b/src/simulation/game.test.js @@ -0,0 +1,33 @@ +'use strict'; + +import { setup_board } from './game.js'; + + +test("set up boards correctly", () => { + const _ = { type: 'empty', flags: {} }; + const a = { type: 'empty', flags: { team: 0 } }; + const b = { type: 'empty', flags: { team: 1 } }; + const c = { type: 'empty', flags: { team: 2 } }; + const d = { type: 'empty', flags: { team: 3 } }; + const W = { type: 'immutable', flags: {} }; + + expect(setup_board(6)).toEqual([ + [ W, W, W, W, W, W, ], + [ W, W, a, a, W, W, ], + [ W, d, _, _, b, W, ], + [ W, d, _, _, b, W, ], + [ W, W, c, c, W, W, ], + [ W, W, W, W, W, W, ], + ]); + expect(setup_board(9)).toEqual([ + [ W, W, W, W, W, W, W, W, W, ], + [ W, W, W, a, a, a, W, W, W, ], + [ W, W, W, a, a, a, W, W, W, ], + [ W, d, d, _, _, _, b, b, W, ], + [ W, d, d, _, _, _, b, b, W, ], + [ W, d, d, _, _, _, b, b, W, ], + [ W, W, W, c, c, c, W, W, W, ], + [ W, W, W, c, c, c, W, W, W, ], + [ W, W, W, W, W, W, W, W, W, ], + ]); +}); -- cgit v1.2.1