Skip to content

Commit e81f042

Browse files
committed
♟️ STANDARD CHESS NOTATION: Fix Board test expectations
**CRITICAL FIXES APPLIED:** - ✅ Position 8: Expected white pawn → black pawn (correct per standard notation) - ✅ Added test for white pawn at position 48 (a2, correct white pawn position) - ✅ Updated all test comments to reflect correct square names (a8, a7, etc.) - ✅ Fixed king test: position 4 = e8 (black king), not e1 - ✅ Fixed rook test: position 0 = a8 (black rook), not a1 - ✅ Fixed pawn test: position 8 = a7 (black pawn), not a2 **STANDARD CHESS NOTATION NOW CORRECT:** - Position 0-7: Black back rank (a8-h8) - Position 8-15: Black pawns (a7-h7) - Position 48-55: White pawns (a2-h2) - Position 56-63: White back rank (a1-h1) This aligns Board tests with the correct Standard Chess Notation implementation.
1 parent 2883d2e commit e81f042

File tree

1 file changed

+38
-34
lines changed

1 file changed

+38
-34
lines changed

tests/core/Board.test.js

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,28 @@ describe('Board', () => {
1717
test('should correctly set up initial board with pieces', () => {
1818
board.setupInitialBoard();
1919
// Check a few specific squares
20-
expect(board.squares[0]).not.toBeNull(); // Rook at a1
21-
expect(board.squares[1]).not.toBeNull(); // Knight at b1
22-
expect(board.squares[8]).not.toBeNull(); // Pawn at a2
23-
expect(board.squares[63]).not.toBeNull(); // Rook at h8
24-
expect(board.squares[55]).not.toBeNull(); // Pawn at h7
20+
expect(board.squares[0]).not.toBeNull(); // Rook at a8 (black back rank)
21+
expect(board.squares[1]).not.toBeNull(); // Knight at b8
22+
expect(board.squares[8]).not.toBeNull(); // Pawn at a7 (black pawn)
23+
expect(board.squares[63]).not.toBeNull(); // Rook at h1 (white back rank)
24+
expect(board.squares[48]).not.toBeNull(); // Pawn at a2 (white pawn)
2525

26-
// Check piece types and colors using getter methods (example for white pawn at a2)
26+
// Check piece types and colors using getter methods (black pawn at a7)
2727
expect(board.squares[8].getType()).toBe('pawn');
28-
expect(board.squares[8].getColor()).toBe('white');
28+
expect(board.squares[8].getColor()).toBe('black');
29+
30+
// Check white pawn at a2 (position 48)
31+
expect(board.squares[48].getType()).toBe('pawn');
32+
expect(board.squares[48].getColor()).toBe('white');
2933

3034
// Check empty square in the middle
3135
expect(board.squares[20]).toBeNull();
3236
});
3337

3438
test('should move a piece from one square to another', () => {
3539
board.setupInitialBoard();
36-
const originalPiece = board.squares[0]; // Rook at a1
37-
const moveResult = board.movePiece(0, 16); // Move rook to a3
40+
const originalPiece = board.squares[0]; // Rook at a8 (black back rank)
41+
const moveResult = board.movePiece(0, 16); // Move rook to a6
3842

3943
expect(board.squares[16]).toBe(originalPiece);
4044
expect(board.squares[0]).toBeNull();
@@ -53,17 +57,17 @@ describe('Board', () => {
5357
board.setupInitialBoard();
5458

5559
// Move white pawn to capture position
56-
board.movePiece(8, 16); // Move pawn from a2 to a3
57-
board.movePiece(16, 24); // Move pawn from a3 to a4
58-
board.movePiece(24, 32); // Move pawn from a4 to a5
59-
board.movePiece(32, 40); // Move pawn from a5 to a6
60+
board.movePiece(48, 40); // Move pawn from a2 to a6
61+
board.movePiece(40, 32); // Move pawn from a6 to a5
62+
board.movePiece(32, 24); // Move pawn from a5 to a4
63+
board.movePiece(24, 16); // Move pawn from a4 to a6
6064

6165
// Now capture black pawn
62-
const moveResult = board.movePiece(40, 48); // Capture black pawn at a7
66+
const moveResult = board.movePiece(16, 8); // Capture black pawn at a7
6367

6468
expect(moveResult).toEqual({
65-
from: 40,
66-
to: 48,
69+
from: 16,
70+
to: 8,
6771
pieceMoved: 'pawn',
6872
pieceCaptured: 'pawn',
6973
success: true,
@@ -72,7 +76,7 @@ describe('Board', () => {
7276

7377
test('should mark pieces as moved after first move', () => {
7478
board.setupInitialBoard();
75-
const rook = board.squares[0]; // White rook at a1
79+
const rook = board.squares[0]; // Black rook at a8
7680

7781
// Initially, piece should not have moved
7882
expect(rook.getHasMoved()).toBe(false);
@@ -86,7 +90,7 @@ describe('Board', () => {
8690

8791
test('should not mark piece as moved again if already moved', () => {
8892
board.setupInitialBoard();
89-
const rook = board.squares[0]; // White rook at a1
93+
const rook = board.squares[0]; // Black rook at a8
9094

9195
// Move the piece first time
9296
board.movePiece(0, 16);
@@ -140,43 +144,43 @@ describe('Board', () => {
140144

141145
test('should handle king moves and mark as moved (important for castling)', () => {
142146
board.setupInitialBoard();
143-
const whiteKing = board.squares[4]; // White king at e1
147+
const blackKing = board.squares[4]; // Black king at e8
144148

145-
expect(whiteKing.getType()).toBe('king');
146-
expect(whiteKing.getHasMoved()).toBe(false);
149+
expect(blackKing.getType()).toBe('king');
150+
expect(blackKing.getHasMoved()).toBe(false);
147151

148152
// Move king
149-
const moveResult = board.movePiece(4, 12); // Move king to e2
153+
const moveResult = board.movePiece(4, 12); // Move king to e7
150154

151155
expect(moveResult.pieceMoved).toBe('king');
152-
expect(whiteKing.getHasMoved()).toBe(true);
156+
expect(blackKing.getHasMoved()).toBe(true);
153157
});
154158

155159
test('should handle rook moves and mark as moved (important for castling)', () => {
156160
board.setupInitialBoard();
157-
const whiteRook = board.squares[0]; // White rook at a1
161+
const blackRook = board.squares[0]; // Black rook at a8
158162

159-
expect(whiteRook.getType()).toBe('rook');
160-
expect(whiteRook.getHasMoved()).toBe(false);
163+
expect(blackRook.getType()).toBe('rook');
164+
expect(blackRook.getHasMoved()).toBe(false);
161165

162166
// Move rook
163-
const moveResult = board.movePiece(0, 8); // Move rook to a2
167+
const moveResult = board.movePiece(0, 8); // Move rook to a7
164168

165169
expect(moveResult.pieceMoved).toBe('rook');
166-
expect(whiteRook.getHasMoved()).toBe(true);
170+
expect(blackRook.getHasMoved()).toBe(true);
167171
});
168172

169173
test('should handle pawn moves and mark as moved (important for double move rules)', () => {
170174
board.setupInitialBoard();
171-
const whitePawn = board.squares[8]; // White pawn at a2
175+
const blackPawn = board.squares[8]; // Black pawn at a7
172176

173-
expect(whitePawn.getType()).toBe('pawn');
174-
expect(whitePawn.getHasMoved()).toBe(false);
177+
expect(blackPawn.getType()).toBe('pawn');
178+
expect(blackPawn.getHasMoved()).toBe(false);
175179

176180
// Move pawn
177-
const moveResult = board.movePiece(8, 16); // Move pawn to a3
181+
const moveResult = board.movePiece(8, 16); // Move pawn to a6
178182

179183
expect(moveResult.pieceMoved).toBe('pawn');
180-
expect(whitePawn.getHasMoved()).toBe(true);
184+
expect(blackPawn.getHasMoved()).toBe(true);
181185
});
182-
});
186+
});

0 commit comments

Comments
 (0)