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 {
 | 
					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);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue