function isValidMove(turn, piece, startSquare, endSquare) { const startFile = startSquare[0]; const endFile = endSquare[0]; const startRank = startSquare[1]; const endRank = endSquare[1]; if (endRank - startRank > 1) { return false; } return startFile === endFile; } describe('Correct pawn moves for whites', function () { it('should be valid guess when same file and one rank ahead', function () { expect(isValidMove('WHITES', 'PAWN', 'e2', 'e3')).toEqual(true); }); it('should be an error when same file but three rank ahead', function () { expect(isValidMove('WHITES', 'PAWN', 'e2', 'e5')).toEqual(false); }); it('should be an error to be on a different file', function () { expect(isValidMove('WHITES', 'PAWN', 'e2', 'd2')).toEqual(false); }); it('should be an error to be on a different file', function () { expect(isValidMove('WHITES', 'PAWN', 'e2', 'c2')).toEqual(false); }); });