clone

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

main
puzzletea / export / pack / render_test.go
render_test.go 1.8K
1package packexport23import (4 "testing"56 "github.com/FelineStateMachine/puzzletea/export/pdf"7 "github.com/FelineStateMachine/puzzletea/puzzle"8)910func TestAnnotatePuzzlesForPrintUsesLegacyModeOrder(t *testing.T) {11 definitions := []puzzle.Definition{{12 Name: "Sudoku",13 Variants: []puzzle.VariantDef{14 puzzle.NewVariantDef(puzzle.VariantSpec{Title: "Sudoku", DefaultElo: 1200}),15 },16 LegacyModes: []puzzle.LegacyModeAlias{17 puzzle.NewLegacyModeAlias(puzzle.LegacyModeAliasSpec{18 Title: "Easy",19 TargetVariantID: puzzle.CanonicalVariantID("Sudoku"),20 PresetElo: 600,21 XPWeight: 1,22 }),23 puzzle.NewLegacyModeAlias(puzzle.LegacyModeAliasSpec{24 Title: "Medium",25 TargetVariantID: puzzle.CanonicalVariantID("Sudoku"),26 PresetElo: 1200,27 XPWeight: 3,28 }),29 puzzle.NewLegacyModeAlias(puzzle.LegacyModeAliasSpec{30 Title: "Hard",31 TargetVariantID: puzzle.CanonicalVariantID("Sudoku"),32 PresetElo: 1800,33 XPWeight: 7,34 }),35 },36 Modes: []puzzle.ModeDef{37 {ID: puzzle.CanonicalModeID("Easy"), Title: "Easy"},38 {ID: puzzle.CanonicalModeID("Medium"), Title: "Medium"},39 {ID: puzzle.CanonicalModeID("Hard"), Title: "Hard"},40 },41 }}42 puzzles := []pdfexport.Puzzle{{43 Category: "Sudoku",44 ModeSelection: "Hard",45 }}4647 AnnotatePuzzlesForPrint(puzzles, definitions)4849 if got, want := puzzles[0].DifficultyScore, 1.0; got != want {50 t.Fatalf("DifficultyScore = %v, want %v", got, want)51 }52 if got, want := puzzles[0].DifficultyConfidence, pdfexport.DifficultyConfidenceHigh; got != want {53 t.Fatalf("DifficultyConfidence = %q, want %q", got, want)54 }55 if got, want := puzzles[0].DifficultySource, "mode-order"; got != want {56 t.Fatalf("DifficultySource = %q, want %q", got, want)57 }58}