MCPcopy
hub / github.com/mum4k/termdash / TestTextDraws

Function TestTextDraws

widgets/text/text_test.go:34–1042  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32)
33
34func 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 },

Callers

nothing calls this directly

Calls 15

MustNewFunction · 0.92
MustNewFunction · 0.92
MustTextFunction · 0.92
MustApplyFunction · 0.92
FgColorFunction · 0.92
TextCellOptsFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
DiffFunction · 0.92
ScrollKeysFunction · 0.85
MaxTextCellsFunction · 0.85
ScrollMouseButtonsFunction · 0.85

Tested by

no test coverage detected