refactor(tests): streamline test cases for ApiResponse, Board, GameContext, Piece, and Square
This commit is contained in:
@@ -6,33 +6,22 @@ import org.scalatest.matchers.should.Matchers
|
||||
|
||||
class RendererAndUnicodeTest extends AnyFunSuite with Matchers:
|
||||
|
||||
private val whiteKing = Piece(Color.White, PieceType.King)
|
||||
private val blackPawn = Piece(Color.Black, PieceType.Pawn)
|
||||
test("unicode mapping covers representative white and black pieces"):
|
||||
Piece(Color.White, PieceType.King).unicode shouldBe "\u2654"
|
||||
Piece(Color.White, PieceType.Queen).unicode shouldBe "\u2655"
|
||||
Piece(Color.Black, PieceType.King).unicode shouldBe "\u265A"
|
||||
Piece(Color.Black, PieceType.Pawn).unicode shouldBe "\u265F"
|
||||
|
||||
test("unicode returns the correct symbol for white king"):
|
||||
whiteKing.unicode shouldBe "\u2654"
|
||||
|
||||
test("unicode returns the correct symbol for black pawn"):
|
||||
blackPawn.unicode shouldBe "\u265F"
|
||||
|
||||
test("render includes board coordinates on top and bottom"):
|
||||
test("render outputs coordinates ranks ansi escapes and piece glyphs"):
|
||||
val board = Board(Map(Square(File.E, Rank.R4) -> Piece(Color.White, PieceType.Queen)))
|
||||
val rendered = Renderer.render(Board(Map.empty))
|
||||
val lines = rendered.trim.split("\\n").toList.map(_.trim)
|
||||
|
||||
lines.head shouldBe "a b c d e f g h"
|
||||
lines.last shouldBe "a b c d e f g h"
|
||||
|
||||
test("render includes rank labels from 8 down to 1"):
|
||||
val rendered = Renderer.render(Board(Map.empty))
|
||||
|
||||
rendered should include("8")
|
||||
rendered should include("1")
|
||||
|
||||
test("render places a piece unicode glyph on occupied square"):
|
||||
val board = Board(Map(Square(File.E, Rank.R4) -> Piece(Color.White, PieceType.Queen)))
|
||||
val rendered = Renderer.render(board)
|
||||
|
||||
rendered should include("\u2655")
|
||||
rendered should include("\u001b[")
|
||||
Renderer.render(board) should include("\u2655")
|
||||
Renderer.render(board) should include("\u001b[")
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user