Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions technical-fundamentals/coding/__tests__/connect4.test.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { describe, it, expect, vi } from "vitest";
import { Connect4, PLAYER_ONE, PLAYER_TWO } from "../connect4.mjs";
import { describe, it, expect } from "vitest";
import { Connect4, PLAYER_ONE } from "../connect4.mjs";

describe("Connect4", () => {
it("It should allow you play within bounds", async () => {
const c4 = new Connect4({ width: 10, height: 10 });
expect(c4.getValue(10, 1)).toBeFalsy();
expect(c4.getValue(9, 1)).toBeFalsy();
c4.play(1);
expect(c4.getValue(10, 1)).toEqual(PLAYER_ONE);
expect(c4.getValue(9, 1)).toEqual(PLAYER_ONE);
});

it("It should do nothing if you play out of bounds", async () => {
Expand Down Expand Up @@ -40,9 +40,9 @@ describe("Connect4", () => {
expect(c4.winner()).toEqual(PLAYER_ONE);
});

it("it should detect diagonal winning", () => {
it("it should detect diagonal winning second", () => {
const c4 = new Connect4({ width: 10, height: 10 });
const plays = [1, 2, 2, 3, 4, 3, 3, 4, 5, 4, 4].reverse();
const plays = [5, 4, 4, 9, 3, 3, 3, 2, 2, 2, 2];
plays.forEach((p) => c4.play(p));
expect(c4.winner()).toEqual(PLAYER_ONE);
});
Expand Down