Skip to content

Commit

Permalink
add test assertion
Browse files Browse the repository at this point in the history
  • Loading branch information
merowin committed May 13, 2024
1 parent 2837120 commit 8ccd58e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
9 changes: 8 additions & 1 deletion packages/shared/src/lib/__tests__/board.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,14 @@ test("create rhombitrihexagonal board", () => {
);
const graph = createGraph(intersections, Color.EMPTY);

// Remark: This test case is not independent of implementation
expect(
graph.reduce<number>(
(prev, _, index, g) => prev + g.neighbors(index).length,
0,
),
).toEqual(6 * 4 + 12 * 3);

// Remark: This assertion is not independent of implementation
// Also see PolygonalBoardHelper lines 4 - 28
expect(graph.neighbors(0)).toEqual([1, 5, 6, 17]);
});
3 changes: 1 addition & 2 deletions packages/shared/src/lib/abstractBoard/boardFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export function createGraph<TIntersection extends Intersection, TColor>(
intersections.indexOf(neighbour),
),
);
const graph = new Graph<TColor>(adjacencyMatrix).fill(startColor);
return graph;
return new Graph<TColor>(adjacencyMatrix).fill(startColor);
}

function createRthBoard<TIntersection extends Intersection>(
Expand Down

0 comments on commit 8ccd58e

Please sign in to comment.