Get 100% test coverage on grid operations

This commit is contained in:
Robin Townsend 2023-02-13 22:24:04 -05:00
parent 58ed372afa
commit 8c818b9ce1

View file

@ -15,6 +15,7 @@ limitations under the License.
*/ */
import { import {
appendItems,
column, column,
cycleTileSize, cycleTileSize,
fillGaps, fillGaps,
@ -72,6 +73,26 @@ function testFillGaps(title: string, input: string, output: string): void {
}); });
} }
testFillGaps(
"does nothing on an empty grid",
`
`,
`
`
);
testFillGaps(
"does nothing if there are no gaps",
`
ab
cd
ef`,
`
ab
cd
ef`
);
testFillGaps( testFillGaps(
"fills a gap", "fills a gap",
` `
@ -245,3 +266,18 @@ cbb
dde dde
ddf` ddf`
); );
test("appendItems appends 1×1 tiles", () => {
const grid1 = `
aab
aac
d`;
const grid2 = `
aab
aac
def`;
const newItems = ["e", "f"].map(
(i) => ({ id: i } as unknown as TileDescriptor)
);
expect(showGrid(appendItems(newItems, mkGrid(grid1)))).toBe(grid2);
});