refactor(tests): enhance test coverage for move application and piece movement logic

This commit is contained in:
2026-04-05 22:03:40 +02:00
parent 4cf39e3e97
commit 3cec5b8898
14 changed files with 773 additions and 97 deletions
@@ -0,0 +1,38 @@
package de.nowchess.ui.utils
import de.nowchess.api.board.{Board, Color, File, Piece, PieceType, Rank, Square}
import org.scalatest.funsuite.AnyFunSuite
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 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"):
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[")