clone

fifteen puzzle games for the terminal, with daily puzzles, weekly ladders and xp, built on bubble tea

chore/regenerate-vhs-gifs
puzzletea / app / view_test.go
view_test.go 1.6K
1package app23import (4 "strings"5 "testing"67 tea "charm.land/bubbletea/v2"8 "github.com/FelineStateMachine/puzzletea/store"9 "github.com/FelineStateMachine/puzzletea/ui"10)1112func TestGameViewRequestsMouseCellMotion(t *testing.T) {13 m := model{14 state: gameView,15 session: sessionState{game: &escapeTrackingGame{}},16 }1718 v := m.View()19 if v.MouseMode != tea.MouseModeCellMotion {20 t.Fatalf("MouseMode = %v, want %v", v.MouseMode, tea.MouseModeCellMotion)21 }22 if !v.KeyboardEnhancements.ReportEventTypes {23 t.Fatal("expected keyboard event type reporting to remain enabled")24 }25}2627func TestPlayMenuViewIncludesNotice(t *testing.T) {28 m := model{29 state: playMenuView,30 width: 80,31 height: 24,32 nav: navigationState{33 playMenu: ui.NewMainMenu(nil),34 },35 notice: noticeState{level: noticeLevelError, message: "Could not load puzzle"},36 }3738 if got := m.viewContent(); !strings.Contains(got, "Could not load puzzle") {39 t.Fatalf("viewContent() missing notice, got %q", got)40 }41}4243func TestContinueViewStaysAtNaturalTableWidth(t *testing.T) {44 s := openAppTestStore(t)45 if err := s.CreateGame(&store.GameRecord{46 Name: "shadow-trail",47 GameType: "Sudoku",48 Mode: "Medium",49 Status: store.StatusInProgress,50 RunKind: store.RunKindNormal,51 }); err != nil {52 t.Fatal(err)53 }54 table, games := ui.InitContinueTable(s, 30)55 m := model{56 state: continueView,57 width: 140,58 height: 30,59 cont: continueState{table: table, games: games},60 }61 m = m.resizeActiveScreen()6263 if got, want := m.cont.table.Width(), ui.ContinueTableWidth(); got != want {64 t.Fatalf("continue table width = %d, want %d", got, want)65 }66}