board module
This commit is contained in:
28
tests/board.test.js
Normal file
28
tests/board.test.js
Normal file
@ -0,0 +1,28 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import {
|
||||
Board,
|
||||
create1dInitialState,
|
||||
create2dRandomGrid,
|
||||
} from "src/modules/board.js";
|
||||
|
||||
describe("Board", () => {
|
||||
const board = new Board(503, 301);
|
||||
test("create1dInitialState onecell", () => {
|
||||
const stateOne = create1dInitialState(board);
|
||||
expect(stateOne.length).toBe(board.width);
|
||||
expect(stateOne).toContain(1);
|
||||
});
|
||||
|
||||
test("create1dInitialState random", () => {
|
||||
const stateRandom = create1dInitialState(board, "random");
|
||||
expect(stateRandom.length).toBe(board.width);
|
||||
expect(stateRandom).toContain(1);
|
||||
});
|
||||
|
||||
test("create2dRandomGrid", () => {
|
||||
const board = new Board(503, 301);
|
||||
const got = create2dRandomGrid(board.width, board.height);
|
||||
expect(got.length).toBe(board.height);
|
||||
expect(got[0].length).toBe(board.width);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user