From 8c818b9ce16dd2d51525d05f98c103e26ea0cc9d Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Mon, 13 Feb 2023 22:24:04 -0500 Subject: [PATCH] Get 100% test coverage on grid operations --- test/video-grid/model-test.ts | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/video-grid/model-test.ts b/test/video-grid/model-test.ts index d71fd2f..cc7741d 100644 --- a/test/video-grid/model-test.ts +++ b/test/video-grid/model-test.ts @@ -15,6 +15,7 @@ limitations under the License. */ import { + appendItems, column, cycleTileSize, 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( "fills a gap", ` @@ -245,3 +266,18 @@ cbb dde 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); +});