| 21 | ) |
| 22 | |
| 23 | func TestCursorStyleHelpers(t *testing.T) { |
| 24 | t.Parallel() |
| 25 | |
| 26 | tests := []struct { |
| 27 | name string |
| 28 | style CursorStyle |
| 29 | visible bool |
| 30 | blinking bool |
| 31 | }{ |
| 32 | {name: "steady block", style: SteadyBlock, visible: true, blinking: false}, |
| 33 | {name: "steady bar", style: SteadyBar, visible: true, blinking: false}, |
| 34 | {name: "steady underline", style: SteadyUnderline, visible: true, blinking: false}, |
| 35 | {name: "blinking block", style: BlinkingBlock, visible: true, blinking: true}, |
| 36 | {name: "hidden blink", style: BlinkingBar.Hide(), visible: false, blinking: true}, |
| 37 | } |
| 38 | |
| 39 | for _, tc := range tests { |
| 40 | tc := tc |
| 41 | t.Run(tc.name, func(t *testing.T) { |
| 42 | t.Parallel() |
| 43 | |
| 44 | if got := tc.style.IsVisible(); got != tc.visible { |
| 45 | t.Fatalf("IsVisible() = %v, want %v", got, tc.visible) |
| 46 | } |
| 47 | if got := tc.style.IsBlinking(); got != tc.blinking { |
| 48 | t.Fatalf("IsBlinking() = %v, want %v", got, tc.blinking) |
| 49 | } |
| 50 | |
| 51 | if got := tc.style.Hide().IsVisible(); got { |
| 52 | t.Fatalf("Hide() should clear visibility") |
| 53 | } |
| 54 | if got := tc.style.Show().IsVisible(); !got { |
| 55 | t.Fatalf("Show() should set visibility") |
| 56 | } |
| 57 | if got := tc.style.Blink().IsBlinking(); !got { |
| 58 | t.Fatalf("Blink() should set blinking") |
| 59 | } |
| 60 | if got := tc.style.Steady().IsBlinking(); got { |
| 61 | t.Fatalf("Steady() should clear blinking") |
| 62 | } |
| 63 | }) |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | func TestModeFormatters(t *testing.T) { |
| 68 | t.Parallel() |