aboutsummaryrefslogtreecommitdiff
path: root/internal/game/casino_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/game/casino_test.go')
-rw-r--r--internal/game/casino_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/internal/game/casino_test.go b/internal/game/casino_test.go
index 0394437..8affe29 100644
--- a/internal/game/casino_test.go
+++ b/internal/game/casino_test.go
@@ -81,6 +81,29 @@ func TestExecuteBetParsesBaccaratSpots(t *testing.T) {
}
}
+func TestCasinoMenuRendersAlignedColoredCommands(t *testing.T) {
+ g := &Game{Casino: casino.NewManager(1)}
+ conn := &casinoTestConn{}
+ sess := &net.Session{Player: player.New("alice"), Conn: conn}
+ g.loggedInChars = map[string]*net.Session{"alice": sess}
+ menu := &casino.MenuView{Kind: casino.MenuSlotCommands, Commands: []casino.MenuCommand{
+ {Command: "bet <amount>", Desc: "Set your wager"},
+ {Command: "spin", Desc: "Spin using your current wager"},
+ }}
+ msg := g.casinoPrivateMessage(sess, "casino_menu", menu, "Your slot machine bet is set to 10.")
+ if !strings.Contains(msg, "You have 0 chips and 0 credits.") {
+ t.Fatalf("missing balance line: %q", msg)
+ }
+ // Commands are painted with the "command" color (0A bold).
+ if !strings.Contains(msg, "\033[1m\033[38;5;10mbet <amount>\033[0m") {
+ t.Fatalf("command not colored: %q", msg)
+ }
+ // Shorter commands are right-padded to align the descriptions.
+ if !strings.Contains(msg, "\033[1m\033[38;5;10mspin \033[0m Spin using your current wager") {
+ t.Fatalf("commands not aligned: %q", msg)
+ }
+}
+
func TestRenderBaccaratSnapshot(t *testing.T) {
snapshot := &casino.BaccaratSnapshot{
Player: []casino.CardView{{Rank: "5", Suit: "clubs"}, {Rank: "4", Suit: "hearts"}},