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

Function TestDrawWidget

container/draw_test.go:32–1024  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestDrawWidget(t *testing.T) {
33 tests := []struct {
34 desc string
35 termSize image.Point
36 container func(ft *faketerm.Terminal) (*Container, error)
37 want func(size image.Point) *faketerm.Terminal
38 wantErr bool
39 }{
40 {
41 desc: "draws widget with container border",
42 termSize: image.Point{9, 5},
43 container: func(ft *faketerm.Terminal) (*Container, error) {
44 return New(
45 ft,
46 Border(linestyle.Light),
47 PlaceWidget(fakewidget.New(widgetapi.Options{})),
48 )
49 },
50 want: func(size image.Point) *faketerm.Terminal {
51 ft := faketerm.MustNew(size)
52 cvs := testcanvas.MustNew(ft.Area())
53 // Container border.
54 testdraw.MustBorder(
55 cvs,
56 cvs.Area(),
57 draw.BorderCellOpts(cell.FgColor(cell.ColorYellow)),
58 )
59
60 // Fake widget border.
61 testdraw.MustBorder(cvs, image.Rect(1, 1, 8, 4))
62 testdraw.MustText(cvs, "(7,3)", image.Point{2, 2})
63 testcanvas.MustApply(cvs, ft)
64 return ft
65 },
66 },
67 {
68 desc: "absolute margin on root container",
69 termSize: image.Point{20, 10},
70 container: func(ft *faketerm.Terminal) (*Container, error) {
71 return New(
72 ft,
73 Border(linestyle.Light),
74 MarginTop(1),
75 MarginRight(2),
76 MarginBottom(3),
77 MarginLeft(4),
78 )
79 },
80 want: func(size image.Point) *faketerm.Terminal {
81 ft := faketerm.MustNew(size)
82 cvs := testcanvas.MustNew(image.Rect(4, 1, 18, 7))
83 // Container border.
84 testdraw.MustBorder(
85 cvs,
86 cvs.Area(),
87 draw.BorderCellOpts(cell.FgColor(cell.ColorYellow)),
88 )
89

Callers

nothing calls this directly

Calls 15

NewFunction · 0.92
MustNewFunction · 0.92
MustNewFunction · 0.92
MustBorderFunction · 0.92
BorderCellOptsFunction · 0.92
FgColorFunction · 0.92
MustTextFunction · 0.92
MustApplyFunction · 0.92
BorderLineStyleFunction · 0.92
MustDrawFunction · 0.92
MustCopyToFunction · 0.92
BorderTitleFunction · 0.92

Tested by

no test coverage detected