Allow the grid to resize with the window width

This commit is contained in:
Robin Townsend 2023-06-17 21:33:54 -04:00
commit afbcea7b66
3 changed files with 109 additions and 13 deletions

View file

@ -21,6 +21,7 @@ import {
fillGaps,
forEachCellInArea,
Grid,
resize,
row,
tryMoveTile,
} from "../../src/video-grid/model";
@ -386,3 +387,52 @@ abb
ccd
cce`
);
function testResize(
title: string,
columns: number,
input: string,
output: string
): void {
test(`resize ${title}`, () => {
expect(showGrid(resize(mkGrid(input), columns))).toBe(output);
});
}
testResize(
"contracts the grid",
2,
`
abbb
cbbb
ddde
dddf
gh`,
`
af
bb
bb
ch
dd
dd
eg`
);
testResize(
"expands the grid",
4,
`
af
bb
bb
ch
dd
dd
eg`,
`
bbbc
bbbf
addd
hddd
ge`
);