Approval-based snapshot testing library for Go (mirror)
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: fix title display in cli/tui

+14 -12
+1
internal/files/files.go
··· 235 235 236 236 for _, entry := range entries { 237 237 if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".snap.new") { 238 + // Remove .snap.new extension to get the title 238 239 name := strings.TrimSuffix(entry.Name(), ".snap.new") 239 240 fullPath := filepath.Join(dir, entry.Name()) 240 241 newSnapshots = append(newSnapshots, SnapshotInfo{
+1 -1
internal/pretty/__snapshots__/diff_box_complex_mixed.snap
··· 8 8 9 9  title: Visual Complex 10 10  test: TestVisualComplex 11 -  file: testvisualcomplex.snap 11 +  file: visual_complex.snap 12 12 13 13 ──────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────────── 14 14 1 │ unchanged1
+1 -1
internal/pretty/__snapshots__/diff_box_large_line_numbers.snap
··· 8 8 9 9  title: Large Line Numbers 10 10  test: TestVisualLarge 11 -  file: testvisuallarge.snap 11 +  file: large_line_numbers.snap 12 12 13 13 ──────────┬───────────────────────────────────────────────────────────────────────────────────────────────────────────────── 14 14  1 │ line 1
+1 -1
internal/pretty/__snapshots__/diff_box_simple_modification.snap
··· 8 8 9 9  title: Visual Test 10 10  test: TestVisualSimple 11 -  file: testvisualsimple.snap 11 +  file: visual_test.snap 12 12 13 13 ──────┬───────────────────────────────────────────────────────────────────────────────────────────────── 14 14 1 │ line1
+1 -1
internal/pretty/boxes.go
··· 33 33 34 34 func DiffSnapshotBox(old, newSnapshot *files.Snapshot, diffLines []diff.DiffLine) string { 35 35 width := TerminalWidth() 36 - snapshotFileName := files.SnapshotFileName(newSnapshot.Test) + ".snap" 36 + snapshotFileName := files.SnapshotFileName(newSnapshot.Title) + ".snap" 37 37 38 38 var sb strings.Builder 39 39 sb.WriteString("─── " + "Snapshot Diff " + strings.Repeat("─", width-15) + "\n\n")
+9 -8
internal/pretty/boxes_test.go
··· 197 197 validation := BoxValidation{ 198 198 Title: "Simple Modification", 199 199 TestName: "TestSimple", 200 - FileName: "testsimple.snap", 200 + FileName: "simple_modification.snap", 201 201 HasTitle: true, 202 202 HasTestName: true, 203 203 HasFileName: true, ··· 239 239 validation := BoxValidation{ 240 240 Title: "Pure Addition", 241 241 TestName: "TestAddition", 242 - FileName: "testaddition.snap", 242 + FileName: "pure_addition.snap", 243 243 HasTitle: true, 244 244 HasTestName: true, 245 245 HasFileName: true, ··· 281 281 validation := BoxValidation{ 282 282 Title: "Pure Deletion", 283 283 TestName: "TestDeletion", 284 - FileName: "testdeletion.snap", 284 + FileName: "pure_deletion.snap", 285 285 HasTitle: true, 286 286 HasTestName: true, 287 287 HasFileName: true, ··· 334 334 validation := BoxValidation{ 335 335 Title: "Complex Mixed", 336 336 TestName: "TestComplexMixed", 337 - FileName: "testcomplexmixed.snap", 337 + FileName: "complex_mixed.snap", 338 338 HasTitle: true, 339 339 HasTestName: true, 340 340 HasFileName: true, ··· 376 376 validation := BoxValidation{ 377 377 Title: "Empty to Content", 378 378 TestName: "TestEmptyOld", 379 - FileName: "testemptyold.snap", 379 + FileName: "empty_to_content.snap", 380 380 HasTitle: true, 381 381 HasTestName: true, 382 382 HasFileName: true, ··· 418 418 validation := BoxValidation{ 419 419 Title: "Content to Empty", 420 420 TestName: "TestEmptyNew", 421 - FileName: "testemptynew.snap", 421 + FileName: "content_to_empty.snap", 422 422 HasTitle: true, 423 423 HasTestName: true, 424 424 HasFileName: true, ··· 468 468 if !strings.Contains(stripped, "test: TestNoTitle") { 469 469 t.Error("Expected test name to be present") 470 470 } 471 - if !strings.Contains(stripped, "file: testnotitle.snap") { 471 + // When title is empty, filename should be based on test name 472 + if !strings.Contains(stripped, "file: .snap") { 472 473 t.Error("Expected file name to be present") 473 474 } 474 475 } ··· 574 575 validation := BoxValidation{ 575 576 Title: "Unicode Test", 576 577 TestName: "TestUnicode", 577 - FileName: "testunicode.snap", 578 + FileName: "unicode_test.snap", 578 579 HasTitle: true, 579 580 HasTestName: true, 580 581 HasFileName: true,