Get 100% test coverage on grid operations
This commit is contained in:
parent
58ed372afa
commit
8c818b9ce1
1 changed files with 36 additions and 0 deletions
|
@ -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);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue