|
|
|
@ -236,6 +236,122 @@ void t.test("withEmptyBoard", async (t) => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("withAdditionalRow", async (t) => { |
|
|
|
|
void t.test("On uninitialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20..."); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withAdditionalRow(); |
|
|
|
|
t.equal(newState?.serialize(), "11x20..."); |
|
|
|
|
t.equal(newState?.rows, 11); |
|
|
|
|
t.equal(newState?.columns, 20); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withAdditionalRow(); |
|
|
|
|
t.equal(newState?.serialize(), "11x20.XO.."); |
|
|
|
|
t.equal(newState?.rows, 11); |
|
|
|
|
t.equal(newState?.columns, 20); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("withoutAdditionalRow", async (t) => { |
|
|
|
|
void t.test("On uninitialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20..."); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalRow(); |
|
|
|
|
t.equal(newState?.serialize(), "9x20..."); |
|
|
|
|
t.equal(newState?.rows, 9); |
|
|
|
|
t.equal(newState?.columns, 20); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalRow(); |
|
|
|
|
t.equal(newState?.serialize(), "9x20.XO.."); |
|
|
|
|
t.equal(newState?.rows, 9); |
|
|
|
|
t.equal(newState?.columns, 20); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board with 1 row", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "0x20.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalRow(); |
|
|
|
|
t.equal(newState?.serialize(), "0x20.XO.."); |
|
|
|
|
t.equal(newState?.rows, 0); |
|
|
|
|
t.equal(newState?.columns, 20); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board with 0 rows", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "0x20.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalRow(); |
|
|
|
|
t.equal(newState?.serialize(), "0x20.XO.."); |
|
|
|
|
t.equal(newState?.rows, 0); |
|
|
|
|
t.equal(newState?.columns, 20); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("withAdditionalColumn", async (t) => { |
|
|
|
|
void t.test("On uninitialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20..."); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withAdditionalColumn(); |
|
|
|
|
t.equal(newState?.serialize(), "10x21..."); |
|
|
|
|
t.equal(newState?.rows, 10); |
|
|
|
|
t.equal(newState?.columns, 21); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withAdditionalColumn(); |
|
|
|
|
t.equal(newState?.serialize(), "10x21.XO.."); |
|
|
|
|
t.equal(newState?.rows, 10); |
|
|
|
|
t.equal(newState?.columns, 21); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("withoutAdditionalColumn", async (t) => { |
|
|
|
|
void t.test("On uninitialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20..."); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalColumn(); |
|
|
|
|
t.equal(newState?.serialize(), "10x19..."); |
|
|
|
|
t.equal(newState?.rows, 10); |
|
|
|
|
t.equal(newState?.columns, 19); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x20.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalColumn(); |
|
|
|
|
t.equal(newState?.serialize(), "10x19.XO.."); |
|
|
|
|
t.equal(newState?.rows, 10); |
|
|
|
|
t.equal(newState?.columns, 19); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board with 1 columns", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x1.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalColumn(); |
|
|
|
|
t.equal(newState?.serialize(), "10x0.XO.."); |
|
|
|
|
t.equal(newState?.rows, 10); |
|
|
|
|
t.equal(newState?.columns, 0); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("On initialized board with 0 columns", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "10x0.XO.X.___"); |
|
|
|
|
|
|
|
|
|
const newState = oldState?.withoutAdditionalColumn(); |
|
|
|
|
t.equal(newState?.serialize(), "10x0.XO.."); |
|
|
|
|
t.equal(newState?.rows, 10); |
|
|
|
|
t.equal(newState?.columns, 0); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
void t.test("withAutoPlayer", async (t) => { |
|
|
|
|
void t.test("On uninitialized board", async (t) => { |
|
|
|
|
const oldState = createAndCheckBoardgameState(t, "2x3..."); |
|
|
|
|