46 lines
1.3 KiB
GDScript
46 lines
1.3 KiB
GDScript
extends "res://addons/gut/test.gd"
|
|
|
|
const Palette = preload("res://scripts/theme/palette.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)
|