🚀 draw world
This commit is contained in:
26
packages/compute/__tests__/grid.spec.ts
Normal file
26
packages/compute/__tests__/grid.spec.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { generateEmptyGrid } from "../generateGrid";
|
||||
import { setColor, getColor, isInside } from "../grid";
|
||||
|
||||
it("should set / get cell", () => {
|
||||
const grid = generateEmptyGrid(2, 3);
|
||||
|
||||
expect(getColor(grid, 0, 1)).toBe(null);
|
||||
|
||||
setColor(grid, 0, 1, 1);
|
||||
|
||||
expect(getColor(grid, 0, 1)).toBe(1);
|
||||
});
|
||||
|
||||
test.each([
|
||||
[0, 1, true],
|
||||
[1, 2, true],
|
||||
|
||||
[-1, 1, false],
|
||||
[0, -1, false],
|
||||
[2, 1, false],
|
||||
[0, 3, false],
|
||||
])("isInside", (x, y, output) => {
|
||||
const grid = generateEmptyGrid(2, 3);
|
||||
|
||||
expect(isInside(grid, x, y)).toBe(output);
|
||||
});
|
||||
Reference in New Issue
Block a user