Files
code_of_conquest_dnd/client/tests/unit/test_palette.gd
Phillip Tarrant 0c12e13ac1 fix(theme): drop redundant const preloads shadowing global class_names
palette.gd / theme_keys.gd already declare `class_name`, so `const Palette =
preload(...)` in every consumer shadowed the global class and emitted 4
editor errors ("has the same name as a global class"). Reference the global
class_names directly. Editor reload now clean; suite 125/125; runtime probe
still builds all 75 showcase nodes with the theme applied.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-10 21:58:34 -05:00

44 lines
1.3 KiB
GDScript

extends "res://addons/gut/test.gd"
func test_core_tokens_are_colors():
assert_true(Palette.BLOOD is Color)
assert_true(Palette.GOLD is Color)
assert_true(Palette.PARCHMENT_CARD is Color)
assert_true(Palette.CREAM is Color)
func test_blood_core_matches_readme_hex():
# #8f3a34 — the primary CTA / danger / selection red.
assert_eq(Palette.BLOOD, Color("8f3a34"))
func test_dark_panel_is_translucent():
assert_almost_eq(Palette.DARK_PANEL_70.a, 0.7, 0.01)
func test_rarity_ladder_has_five_ordered_colors():
assert_eq(Palette.RARITY.size(), 5)
assert_eq(Palette.rarity_color(0), Color("8a8378")) # common
assert_eq(Palette.rarity_color(4), Color("c8963f")) # legendary
func test_rarity_color_clamps_out_of_range():
# Out-of-range must NOT index-error (would emit an engine error -> fail).
assert_eq(Palette.rarity_color(-3), Palette.RARITY[0])
assert_eq(Palette.rarity_color(99), Palette.RARITY[4])
func test_stat_bar_returns_from_to_pair():
var hp = Palette.stat_bar(&"hp")
assert_eq(hp.size(), 2)
assert_eq(hp[0], Color("b8524a"))
assert_eq(hp[1], Color("8f3a34"))
func test_stat_bar_unknown_kind_is_safe():
# Unknown kind returns a grey pair, never null / error.
var pair = Palette.stat_bar(&"nonsense")
assert_eq(pair.size(), 2)
assert_true(pair[0] is Color)