cli + tui to publish to leaflet (wip) & manage tasks, notes & watch/read lists 🍃
charm leaflet readability golang
at main 727 lines 21 kB view raw
1package ui 2 3import ( 4 "strings" 5 "testing" 6 7 "github.com/charmbracelet/lipgloss" 8 "github.com/stormlightlabs/noteleaf/internal/models" 9) 10 11func TestGetStatusSymbol(t *testing.T) { 12 testCases := []struct { 13 status string 14 expected string 15 }{ 16 {models.StatusTodo, StatusTodoSymbol}, 17 {models.StatusInProgress, StatusInProgressSymbol}, 18 {models.StatusBlocked, StatusBlockedSymbol}, 19 {models.StatusDone, StatusDoneSymbol}, 20 {models.StatusAbandoned, StatusAbandonedSymbol}, 21 {models.StatusPending, StatusPendingSymbol}, 22 {models.StatusCompleted, StatusCompletedSymbol}, 23 {models.StatusDeleted, StatusDeletedSymbol}, 24 {"unknown", StatusPendingSymbol}, 25 } 26 27 for _, tc := range testCases { 28 t.Run("status_"+tc.status, func(t *testing.T) { 29 result := GetStatusSymbol(tc.status) 30 if result != tc.expected { 31 t.Errorf("Expected symbol %s for status %s, got %s", tc.expected, tc.status, result) 32 } 33 }) 34 } 35} 36 37func TestGetStatusStyle(t *testing.T) { 38 testCases := []struct { 39 status string 40 style lipgloss.Style 41 }{ 42 {models.StatusTodo, TodoStyle}, 43 {models.StatusInProgress, InProgressStyle}, 44 {models.StatusBlocked, BlockedStyle}, 45 {models.StatusDone, DoneStyle}, 46 {models.StatusAbandoned, AbandonedStyle}, 47 {models.StatusPending, PendingStyle}, 48 {models.StatusCompleted, CompletedStyle}, 49 {models.StatusDeleted, DeletedStyle}, 50 {"unknown", PendingStyle}, 51 } 52 53 for _, tc := range testCases { 54 t.Run("style_"+tc.status, func(t *testing.T) { 55 result := GetStatusStyle(tc.status) 56 expectedColor := tc.style.GetForeground() 57 resultColor := result.GetForeground() 58 if expectedColor != resultColor { 59 t.Errorf("Expected color %s for status %s, got %s", expectedColor, tc.status, resultColor) 60 } 61 }) 62 } 63} 64 65func TestFormatStatusIndicator(t *testing.T) { 66 testCases := []string{ 67 models.StatusTodo, 68 models.StatusInProgress, 69 models.StatusBlocked, 70 models.StatusDone, 71 models.StatusAbandoned, 72 } 73 74 for _, status := range testCases { 75 t.Run("format_indicator_"+status, func(t *testing.T) { 76 result := FormatStatusIndicator(status) 77 expectedSymbol := GetStatusSymbol(status) 78 79 if !strings.Contains(result, expectedSymbol) { 80 t.Errorf("Expected formatted indicator for %s to contain symbol %s", status, expectedSymbol) 81 } 82 83 if result == "" { 84 t.Errorf("Expected non-empty formatted indicator for status %s", status) 85 } 86 }) 87 } 88} 89 90func TestFormatStatusWithText(t *testing.T) { 91 testCases := []string{ 92 models.StatusTodo, 93 models.StatusInProgress, 94 models.StatusBlocked, 95 models.StatusDone, 96 models.StatusAbandoned, 97 } 98 99 for _, status := range testCases { 100 t.Run("format_with_text_"+status, func(t *testing.T) { 101 result := FormatStatusWithText(status) 102 expectedSymbol := GetStatusSymbol(status) 103 104 if !strings.Contains(result, expectedSymbol) { 105 t.Errorf("Expected formatted status for %s to contain symbol %s", status, expectedSymbol) 106 } 107 if !strings.Contains(result, status) { 108 t.Errorf("Expected formatted status for %s to contain status text", status) 109 } 110 111 if result == "" { 112 t.Errorf("Expected non-empty formatted status for %s", status) 113 } 114 }) 115 } 116} 117 118func TestGetStatusDescription(t *testing.T) { 119 testCases := []struct { 120 status string 121 description string 122 }{ 123 {models.StatusTodo, "Ready to start"}, 124 {models.StatusInProgress, "Currently working"}, 125 {models.StatusBlocked, "Waiting on dependency"}, 126 {models.StatusDone, "Completed successfully"}, 127 {models.StatusAbandoned, "No longer relevant"}, 128 {models.StatusPending, "Pending (legacy)"}, 129 {models.StatusCompleted, "Completed (legacy)"}, 130 {models.StatusDeleted, "Deleted (legacy)"}, 131 {"unknown", "Unknown status"}, 132 } 133 134 for _, tc := range testCases { 135 t.Run("description_"+tc.status, func(t *testing.T) { 136 result := GetStatusDescription(tc.status) 137 if result != tc.description { 138 t.Errorf("Expected description %s for status %s, got %s", tc.description, tc.status, result) 139 } 140 }) 141 } 142} 143 144func TestFormatTaskStatus(t *testing.T) { 145 t.Run("nil_task", func(t *testing.T) { 146 result := FormatTaskStatus(nil) 147 if result != "" { 148 t.Errorf("Expected empty string for nil task, got %s", result) 149 } 150 }) 151 152 testCases := []string{ 153 models.StatusTodo, 154 models.StatusInProgress, 155 models.StatusBlocked, 156 models.StatusDone, 157 models.StatusAbandoned, 158 } 159 160 for _, status := range testCases { 161 t.Run("format_task_status_"+status, func(t *testing.T) { 162 task := &models.Task{ 163 ID: 1, 164 Status: status, 165 } 166 167 result := FormatTaskStatus(task) 168 expectedSymbol := GetStatusSymbol(status) 169 expectedDescription := GetStatusDescription(status) 170 171 if !strings.Contains(result, expectedSymbol) { 172 t.Errorf("Expected task status format to contain symbol %s", expectedSymbol) 173 } 174 if !strings.Contains(result, status) { 175 t.Errorf("Expected task status format to contain status %s", status) 176 } 177 if !strings.Contains(result, expectedDescription) { 178 t.Errorf("Expected task status format to contain description %s", expectedDescription) 179 } 180 181 if result == "" { 182 t.Errorf("Expected non-empty formatted task status for %s", status) 183 } 184 }) 185 } 186} 187 188func TestStatusLegend(t *testing.T) { 189 result := StatusLegend() 190 191 if result == "" { 192 t.Error("Expected non-empty status legend") 193 } 194 195 expectedStatuses := []string{ 196 models.StatusTodo, 197 models.StatusInProgress, 198 models.StatusBlocked, 199 models.StatusDone, 200 models.StatusAbandoned, 201 } 202 203 for _, status := range expectedStatuses { 204 expectedSymbol := GetStatusSymbol(status) 205 if !strings.Contains(result, expectedSymbol) { 206 t.Errorf("Expected legend to contain symbol %s for status %s", expectedSymbol, status) 207 } 208 if !strings.Contains(result, status) { 209 t.Errorf("Expected legend to contain status text %s", status) 210 } 211 } 212} 213 214func TestGetAllStatusSymbols(t *testing.T) { 215 symbols := GetAllStatusSymbols() 216 217 expectedSymbols := map[string]string{ 218 models.StatusTodo: StatusTodoSymbol, 219 models.StatusInProgress: StatusInProgressSymbol, 220 models.StatusBlocked: StatusBlockedSymbol, 221 models.StatusDone: StatusDoneSymbol, 222 models.StatusAbandoned: StatusAbandonedSymbol, 223 models.StatusPending: StatusPendingSymbol, 224 models.StatusCompleted: StatusCompletedSymbol, 225 models.StatusDeleted: StatusDeletedSymbol, 226 } 227 228 if len(symbols) != len(expectedSymbols) { 229 t.Errorf("Expected %d status symbols, got %d", len(expectedSymbols), len(symbols)) 230 } 231 232 for status, expectedSymbol := range expectedSymbols { 233 if symbol, exists := symbols[status]; !exists { 234 t.Errorf("Expected status %s to exist in symbols map", status) 235 } else if symbol != expectedSymbol { 236 t.Errorf("Expected symbol %s for status %s, got %s", expectedSymbol, status, symbol) 237 } 238 } 239} 240 241func TestIsValidStatusTransition(t *testing.T) { 242 testCases := []struct { 243 from string 244 to string 245 expected bool 246 }{ 247 {models.StatusTodo, models.StatusInProgress, true}, 248 {models.StatusTodo, models.StatusBlocked, true}, 249 {models.StatusTodo, models.StatusDone, true}, 250 {models.StatusTodo, models.StatusAbandoned, true}, 251 {models.StatusTodo, models.StatusTodo, false}, 252 253 {models.StatusInProgress, models.StatusTodo, true}, 254 {models.StatusInProgress, models.StatusBlocked, true}, 255 {models.StatusInProgress, models.StatusDone, true}, 256 {models.StatusInProgress, models.StatusAbandoned, true}, 257 {models.StatusInProgress, models.StatusInProgress, false}, 258 259 {models.StatusBlocked, models.StatusTodo, true}, 260 {models.StatusBlocked, models.StatusInProgress, true}, 261 {models.StatusBlocked, models.StatusDone, true}, 262 {models.StatusBlocked, models.StatusAbandoned, true}, 263 {models.StatusBlocked, models.StatusBlocked, false}, 264 265 {models.StatusDone, models.StatusTodo, true}, 266 {models.StatusDone, models.StatusInProgress, true}, 267 {models.StatusDone, models.StatusBlocked, false}, 268 {models.StatusDone, models.StatusAbandoned, false}, 269 {models.StatusDone, models.StatusDone, false}, 270 271 {models.StatusAbandoned, models.StatusTodo, true}, 272 {models.StatusAbandoned, models.StatusInProgress, true}, 273 {models.StatusAbandoned, models.StatusBlocked, false}, 274 {models.StatusAbandoned, models.StatusDone, false}, 275 {models.StatusAbandoned, models.StatusAbandoned, false}, 276 277 {models.StatusPending, models.StatusTodo, true}, 278 {models.StatusPending, models.StatusInProgress, true}, 279 {models.StatusPending, models.StatusBlocked, false}, 280 {models.StatusCompleted, models.StatusDone, true}, 281 {models.StatusCompleted, models.StatusTodo, false}, 282 283 {"unknown", models.StatusTodo, false}, 284 {models.StatusTodo, "unknown", false}, 285 } 286 287 for _, tc := range testCases { 288 t.Run("transition_"+tc.from+"_to_"+tc.to, func(t *testing.T) { 289 result := IsValidStatusTransition(tc.from, tc.to) 290 if result != tc.expected { 291 t.Errorf("Expected transition from %s to %s to be %v, got %v", 292 tc.from, tc.to, tc.expected, result) 293 } 294 }) 295 } 296} 297 298func TestUnicodeSymbolConstants(t *testing.T) { 299 symbols := []struct { 300 name string 301 symbol string 302 code string 303 }{ 304 {"TodoSymbol", StatusTodoSymbol, "●"}, 305 {"InProgressSymbol", StatusInProgressSymbol, "◐"}, 306 {"BlockedSymbol", StatusBlockedSymbol, "■"}, 307 {"DoneSymbol", StatusDoneSymbol, "✓"}, 308 {"AbandonedSymbol", StatusAbandonedSymbol, "⚫"}, 309 {"PendingSymbol", StatusPendingSymbol, "○"}, 310 {"CompletedSymbol", StatusCompletedSymbol, "✓"}, 311 {"DeletedSymbol", StatusDeletedSymbol, "✗"}, 312 } 313 314 for _, s := range symbols { 315 t.Run("symbol_"+s.name, func(t *testing.T) { 316 if s.symbol != s.code { 317 t.Errorf("Expected %s to be %s, got %s", s.name, s.code, s.symbol) 318 } 319 }) 320 } 321 322 symbolMap := make(map[string][]string) 323 for _, s := range symbols { 324 symbolMap[s.symbol] = append(symbolMap[s.symbol], s.name) 325 } 326 327 for symbol, names := range symbolMap { 328 if len(names) > 1 && symbol != "✓" { 329 t.Errorf("Symbol %s is used by multiple constants: %v", symbol, names) 330 } 331 } 332} 333 334func TestStyleConstants(t *testing.T) { 335 styles := []struct { 336 name string 337 style lipgloss.Style 338 }{ 339 {"TodoStyle", TodoStyle}, 340 {"InProgressStyle", InProgressStyle}, 341 {"BlockedStyle", BlockedStyle}, 342 {"DoneStyle", DoneStyle}, 343 {"AbandonedStyle", AbandonedStyle}, 344 {"PendingStyle", PendingStyle}, 345 {"CompletedStyle", CompletedStyle}, 346 {"DeletedStyle", DeletedStyle}, 347 } 348 349 for _, s := range styles { 350 t.Run("style_"+s.name, func(t *testing.T) { 351 testText := "test" 352 rendered := s.style.Render(testText) 353 // In test environment without terminal, just check that rendering produces output 354 if rendered == "" { 355 t.Errorf("Expected %s to produce output when rendering text", s.name) 356 } 357 }) 358 } 359} 360 361// Priority UI Tests 362 363func TestGetPrioritySymbol(t *testing.T) { 364 testCases := []struct { 365 priority string 366 expected string 367 }{ 368 {models.PriorityHigh, PriorityHighSymbol}, 369 {models.PriorityMedium, PriorityMediumSymbol}, 370 {models.PriorityLow, PriorityLowSymbol}, 371 {"", PriorityNoneSymbol}, 372 {"A", PriorityHighSymbol}, 373 {"Z", PriorityHighSymbol}, 374 {"1", PriorityLowSymbol}, 375 {"2", PriorityMediumSymbol}, 376 {"3", PriorityMediumSymbol}, 377 {"4", PriorityHighSymbol}, 378 {"5", PriorityHighSymbol}, 379 {"unknown", PriorityNoneSymbol}, 380 } 381 382 for _, tc := range testCases { 383 t.Run("priority_symbol_"+tc.priority, func(t *testing.T) { 384 result := GetPrioritySymbol(tc.priority) 385 if result != tc.expected { 386 t.Errorf("Expected symbol %s for priority %s, got %s", tc.expected, tc.priority, result) 387 } 388 }) 389 } 390} 391 392func TestGetPriorityPattern(t *testing.T) { 393 testCases := []struct { 394 priority string 395 expected string 396 }{ 397 {models.PriorityHigh, PriorityHighPattern}, 398 {models.PriorityMedium, PriorityMediumPattern}, 399 {models.PriorityLow, PriorityLowPattern}, 400 {"", PriorityNonePattern}, 401 {"A", PriorityHighPattern}, 402 {"C", PriorityHighPattern}, 403 {"M", PriorityMediumPattern}, 404 {"Z", PriorityLowPattern}, 405 {"1", PriorityLowPattern}, 406 {"2", PriorityMediumPattern}, 407 {"3", PriorityMediumPattern}, 408 {"4", PriorityHighPattern}, 409 {"5", PriorityHighPattern}, 410 {"unknown", PriorityNonePattern}, 411 } 412 413 for _, tc := range testCases { 414 t.Run("priority_pattern_"+tc.priority, func(t *testing.T) { 415 result := GetPriorityPattern(tc.priority) 416 if result != tc.expected { 417 t.Errorf("Expected pattern %s for priority %s, got %s", tc.expected, tc.priority, result) 418 } 419 }) 420 } 421} 422 423func TestGetPriorityStyle(t *testing.T) { 424 testCases := []struct { 425 priority string 426 style lipgloss.Style 427 }{ 428 {models.PriorityHigh, PriorityHighStyle}, 429 {models.PriorityMedium, PriorityMediumStyle}, 430 {models.PriorityLow, PriorityLowStyle}, 431 {"", PriorityNoneStyle}, 432 {"A", PriorityLegacyStyle}, 433 {"1", PriorityLegacyStyle}, 434 {"unknown", PriorityNoneStyle}, 435 } 436 437 for _, tc := range testCases { 438 t.Run("priority_style_"+tc.priority, func(t *testing.T) { 439 result := GetPriorityStyle(tc.priority) 440 expectedColor := tc.style.GetForeground() 441 resultColor := result.GetForeground() 442 if expectedColor != resultColor { 443 t.Errorf("Expected color %s for priority %s, got %s", expectedColor, tc.priority, resultColor) 444 } 445 }) 446 } 447} 448 449func TestFormatPriorityIndicator(t *testing.T) { 450 testCases := []string{models.PriorityHigh, models.PriorityMedium, models.PriorityLow, "", "A", "1"} 451 452 for _, priority := range testCases { 453 t.Run("format_priority_indicator_"+priority, func(t *testing.T) { 454 got := FormatPriorityIndicator(priority) 455 want := GetPriorityPattern(priority) 456 457 if !strings.Contains(got, want) { 458 t.Errorf("Expected formatted priority indicator for %s to contain pattern %s", priority, want) 459 } 460 461 if got == "" { 462 t.Errorf("Expected non-empty formatted priority indicator for priority %s", priority) 463 } 464 }) 465 } 466} 467 468func TestFormatPriorityWithText(t *testing.T) { 469 testCases := []struct { 470 priority string 471 shouldContain []string 472 }{ 473 {models.PriorityHigh, []string{PriorityHighPattern, models.PriorityHigh}}, 474 {models.PriorityMedium, []string{PriorityMediumPattern, models.PriorityMedium}}, 475 {models.PriorityLow, []string{PriorityLowPattern, models.PriorityLow}}, 476 {"", []string{PriorityNonePattern, "None"}}, 477 {"A", []string{PriorityHighPattern, "A"}}, 478 {"1", []string{PriorityLowPattern, "1"}}, 479 } 480 481 for _, tc := range testCases { 482 t.Run("format_priority_with_text_"+tc.priority, func(t *testing.T) { 483 got := FormatPriorityWithText(tc.priority) 484 485 for _, want := range tc.shouldContain { 486 if !strings.Contains(got, want) { 487 t.Errorf("Expected formatted priority for %s to contain %s, got %s", tc.priority, want, got) 488 } 489 } 490 491 if got == "" { 492 t.Errorf("Expected non-empty formatted priority for %s", tc.priority) 493 } 494 }) 495 } 496} 497 498func TestGetPriorityDescription(t *testing.T) { 499 testCases := []struct { 500 priority string 501 description string 502 }{ 503 {models.PriorityHigh, "Urgent - do first"}, 504 {models.PriorityMedium, "Important - schedule soon"}, 505 {models.PriorityLow, "Nice to have - when time permits"}, 506 {"", "No priority set"}, 507 {"A", "Priority A (legacy)"}, 508 {"Z", "Priority Z (legacy)"}, 509 {"1", "Priority 1 (lowest)"}, 510 {"2", "Priority 2 (low)"}, 511 {"3", "Priority 3 (medium)"}, 512 {"4", "Priority 4 (high)"}, 513 {"5", "Priority 5 (highest)"}, 514 {"unknown", "Unknown priority"}, 515 } 516 517 for _, tc := range testCases { 518 t.Run("priority_description_"+tc.priority, func(t *testing.T) { 519 got := GetPriorityDescription(tc.priority) 520 want := tc.description 521 if got != want { 522 t.Errorf("Expected description %s for priority %s, got %s", want, tc.priority, got) 523 } 524 }) 525 } 526} 527 528func TestFormatTaskPriority(t *testing.T) { 529 t.Run("nil_task", func(t *testing.T) { 530 got := FormatTaskPriority(nil) 531 if got != "" { 532 t.Errorf("Expected empty string for nil task, got %s", got) 533 } 534 }) 535 536 testCases := []struct { 537 priority string 538 shouldContain []string 539 }{ 540 {models.PriorityHigh, []string{PriorityHighPattern, models.PriorityHigh, "Urgent - do first"}}, 541 {models.PriorityMedium, []string{PriorityMediumPattern, models.PriorityMedium, "Important - schedule soon"}}, 542 {models.PriorityLow, []string{PriorityLowPattern, models.PriorityLow, "Nice to have - when time permits"}}, 543 {"", []string{PriorityNonePattern, "No priority set"}}, 544 {"A", []string{PriorityHighPattern, "A", "Priority A (legacy)"}}, 545 {"1", []string{PriorityLowPattern, "1", "Priority 1 (lowest)"}}, 546 } 547 548 for _, tc := range testCases { 549 t.Run("format_task_priority_"+tc.priority, func(t *testing.T) { 550 task := &models.Task{ID: 1, Priority: tc.priority} 551 got := FormatTaskPriority(task) 552 553 for _, want := range tc.shouldContain { 554 if !strings.Contains(got, want) { 555 t.Errorf("Expected task priority format to contain %s, got %s", want, got) 556 } 557 } 558 559 if got == "" { 560 t.Errorf("Expected non-empty formatted task priority for %s", tc.priority) 561 } 562 }) 563 } 564} 565 566func TestPriorityLegend(t *testing.T) { 567 got := PriorityLegend() 568 569 if got == "" { 570 t.Error("Expected non-empty priority legend") 571 } 572 573 expectedPriorities := []string{models.PriorityHigh, models.PriorityMedium, models.PriorityLow, "None"} 574 expectedPatterns := []string{PriorityHighPattern, PriorityMediumPattern, PriorityLowPattern, PriorityNonePattern} 575 576 for _, want := range expectedPriorities { 577 if !strings.Contains(got, want) { 578 t.Errorf("Expected legend to contain priority text %s", want) 579 } 580 } 581 582 for _, want := range expectedPatterns { 583 if !strings.Contains(got, want) { 584 t.Errorf("Expected legend to contain pattern %s", want) 585 } 586 } 587} 588 589func TestGetAllPrioritySymbols(t *testing.T) { 590 symbols := GetAllPrioritySymbols() 591 592 expectedSymbols := map[string]string{ 593 models.PriorityHigh: PriorityHighSymbol, 594 models.PriorityMedium: PriorityMediumSymbol, 595 models.PriorityLow: PriorityLowSymbol, 596 "": PriorityNoneSymbol, 597 } 598 599 if len(symbols) != len(expectedSymbols) { 600 t.Errorf("Expected %d priority symbols, got %d", len(expectedSymbols), len(symbols)) 601 } 602 603 for priority, expectedSymbol := range expectedSymbols { 604 if symbol, exists := symbols[priority]; !exists { 605 t.Errorf("Expected priority %s to exist in symbols map", priority) 606 } else if symbol != expectedSymbol { 607 t.Errorf("Expected symbol %s for priority %s, got %s", expectedSymbol, priority, symbol) 608 } 609 } 610} 611 612func TestGetAllPriorityPatterns(t *testing.T) { 613 patterns := GetAllPriorityPatterns() 614 615 expectedPatterns := map[string]string{ 616 models.PriorityHigh: PriorityHighPattern, 617 models.PriorityMedium: PriorityMediumPattern, 618 models.PriorityLow: PriorityLowPattern, 619 "": PriorityNonePattern, 620 } 621 622 if len(patterns) != len(expectedPatterns) { 623 t.Errorf("Expected %d priority patterns, got %d", len(expectedPatterns), len(patterns)) 624 } 625 626 for priority, want := range expectedPatterns { 627 if got, exists := patterns[priority]; !exists { 628 t.Errorf("Expected priority %s to exist in patterns map", priority) 629 } else if got != want { 630 t.Errorf("Expected pattern %s for priority %s, got %s", want, priority, got) 631 } 632 } 633} 634 635func TestGetPriorityDisplayType(t *testing.T) { 636 testCases := []struct { 637 priority string 638 expected string 639 }{ 640 {models.PriorityHigh, "text"}, 641 {models.PriorityMedium, "text"}, 642 {models.PriorityLow, "text"}, 643 {"1", "numeric"}, 644 {"2", "numeric"}, 645 {"3", "numeric"}, 646 {"4", "numeric"}, 647 {"5", "numeric"}, 648 {"A", "legacy"}, 649 {"Z", "legacy"}, 650 {"", "none"}, 651 {"unknown", "unknown"}, 652 } 653 654 for _, tc := range testCases { 655 t.Run("priority_display_type_"+tc.priority, func(t *testing.T) { 656 got := GetPriorityDisplayType(tc.priority) 657 if got != tc.expected { 658 t.Errorf("Expected display type %s for priority %s, got %s", tc.expected, tc.priority, got) 659 } 660 }) 661 } 662} 663 664func TestPriorityUnicodeSymbolConstants(t *testing.T) { 665 symbols := []struct { 666 name string 667 symbol string 668 code string 669 }{ 670 {"PriorityHighSymbol", PriorityHighSymbol, "★"}, 671 {"PriorityMediumSymbol", PriorityMediumSymbol, "☆"}, 672 {"PriorityLowSymbol", PriorityLowSymbol, "◦"}, 673 {"PriorityNoneSymbol", PriorityNoneSymbol, "○"}, 674 } 675 676 for _, s := range symbols { 677 t.Run("priority_symbol_"+s.name, func(t *testing.T) { 678 if s.symbol != s.code { 679 t.Errorf("Expected %s to be %s, got %s", s.name, s.code, s.symbol) 680 } 681 }) 682 } 683} 684 685func TestPriorityPatternConstants(t *testing.T) { 686 patterns := []struct { 687 name string 688 pattern string 689 code string 690 }{ 691 {"PriorityHighPattern", PriorityHighPattern, "★★★"}, 692 {"PriorityMediumPattern", PriorityMediumPattern, "★★☆"}, 693 {"PriorityLowPattern", PriorityLowPattern, "★☆☆"}, 694 {"PriorityNonePattern", PriorityNonePattern, "☆☆☆"}, 695 } 696 697 for _, p := range patterns { 698 t.Run("priority_pattern_"+p.name, func(t *testing.T) { 699 if p.pattern != p.code { 700 t.Errorf("Expected %s to be %s, got %s", p.name, p.code, p.pattern) 701 } 702 }) 703 } 704} 705 706func TestPriorityStyleConstants(t *testing.T) { 707 styles := []struct { 708 name string 709 style lipgloss.Style 710 }{ 711 {"PriorityHighStyle", PriorityHighStyle}, 712 {"PriorityMediumStyle", PriorityMediumStyle}, 713 {"PriorityLowStyle", PriorityLowStyle}, 714 {"PriorityNoneStyle", PriorityNoneStyle}, 715 {"PriorityLegacyStyle", PriorityLegacyStyle}, 716 } 717 718 for _, s := range styles { 719 t.Run("priority_style_"+s.name, func(t *testing.T) { 720 testText := "test" 721 rendered := s.style.Render(testText) 722 if rendered == "" { 723 t.Errorf("Expected %s to produce output when rendering text", s.name) 724 } 725 }) 726 } 727}