(t *testing.T)
| 32 | ) |
| 33 | |
| 34 | func TestTextDraws(t *testing.T) { |
| 35 | tests := []struct { |
| 36 | desc string |
| 37 | canvas image.Rectangle |
| 38 | meta *widgetapi.Meta |
| 39 | opts []Option |
| 40 | writes func(*Text) error |
| 41 | events func(*Text) |
| 42 | want func(size image.Point) *faketerm.Terminal |
| 43 | wantErr bool |
| 44 | wantWriteErr bool |
| 45 | }{ |
| 46 | { |
| 47 | desc: "fails when scroll keys aren't unique", |
| 48 | opts: []Option{ |
| 49 | ScrollKeys('a', 'a', 'a', 'a'), |
| 50 | }, |
| 51 | canvas: image.Rect(0, 0, 1, 1), |
| 52 | want: func(size image.Point) *faketerm.Terminal { |
| 53 | return faketerm.MustNew(size) |
| 54 | }, |
| 55 | wantErr: true, |
| 56 | }, |
| 57 | { |
| 58 | desc: "fails when MaxTextCells is negative", |
| 59 | opts: []Option{ |
| 60 | MaxTextCells(-1), |
| 61 | }, |
| 62 | canvas: image.Rect(0, 0, 1, 1), |
| 63 | want: func(size image.Point) *faketerm.Terminal { |
| 64 | return faketerm.MustNew(size) |
| 65 | }, |
| 66 | wantErr: true, |
| 67 | }, |
| 68 | { |
| 69 | desc: "fails when scroll mouse buttons aren't unique", |
| 70 | opts: []Option{ |
| 71 | ScrollMouseButtons(mouse.ButtonLeft, mouse.ButtonLeft), |
| 72 | }, |
| 73 | canvas: image.Rect(0, 0, 1, 1), |
| 74 | want: func(size image.Point) *faketerm.Terminal { |
| 75 | return faketerm.MustNew(size) |
| 76 | }, |
| 77 | wantErr: true, |
| 78 | }, |
| 79 | { |
| 80 | desc: "empty when no written text", |
| 81 | canvas: image.Rect(0, 0, 1, 1), |
| 82 | want: func(size image.Point) *faketerm.Terminal { |
| 83 | return faketerm.MustNew(size) |
| 84 | }, |
| 85 | }, |
| 86 | { |
| 87 | desc: "write fails for invalid text", |
| 88 | canvas: image.Rect(0, 0, 1, 1), |
| 89 | writes: func(widget *Text) error { |
| 90 | return widget.Write("\thello") |
| 91 | }, |
nothing calls this directly
no test coverage detected