types_test.go RawHistoryFolder

1package domain
2
3import "testing"
4
5func TestAnchor(t *testing.T) {
6	tests := []struct {
7		name   string
8		anchor Anchor
9		valid  bool
10		text   string
11	}{
12		{"center", AnchorCenter, true, "center"},
13		{"top left", AnchorTopLeft, true, "top-left"},
14		{"top", AnchorTop, true, "top"},
15		{"top right", AnchorTopRight, true, "top-right"},
16		{"left", AnchorLeft, true, "left"},
17		{"right", AnchorRight, true, "right"},
18		{"bottom left", AnchorBottomLeft, true, "bottom-left"},
19		{"bottom", AnchorBottom, true, "bottom"},
20		{"bottom right", AnchorBottomRight, true, "bottom-right"},
21		{"invalid", Anchor(255), false, "unknown"},
22	}
23
24	if AnchorCenter != 0 {
25		t.Errorf("AnchorCenter = %d, want 0", AnchorCenter)
26	}
27
28	for _, tt := range tests {
29		t.Run(tt.name, func(t *testing.T) {
30			if got := tt.anchor.Valid(); got != tt.valid {
31				t.Errorf("Anchor(%d).Valid() = %v, want %v", tt.anchor, got, tt.valid)
32			}
33			if got := tt.anchor.String(); got != tt.text {
34				t.Errorf("Anchor(%d).String() = %q, want %q", tt.anchor, got, tt.text)
35			}
36		})
37	}
38}
39
40func TestParseAnchor(t *testing.T) {
41	tests := []struct {
42		input string
43		want  Anchor
44		ok    bool
45	}{
46		{"center", AnchorCenter, true},
47		{" TOP-LEFT ", AnchorTopLeft, true},
48		{"Top", AnchorTop, true},
49		{"top-right", AnchorTopRight, true},
50		{"LEFT", AnchorLeft, true},
51		{"right", AnchorRight, true},
52		{"bottom-left", AnchorBottomLeft, true},
53		{"Bottom", AnchorBottom, true},
54		{"bottom-right", AnchorBottomRight, true},
55		{"auto", AnchorCenter, false},
56		{"", AnchorCenter, false},
57		{"diagonal", AnchorCenter, false},
58	}
59
60	for _, tt := range tests {
61		t.Run(tt.input, func(t *testing.T) {
62			got, ok := ParseAnchor(tt.input)
63			if got != tt.want || ok != tt.ok {
64				t.Errorf("ParseAnchor(%q) = (%q, %v), want (%q, %v)", tt.input, got, ok, tt.want, tt.ok)
65			}
66		})
67	}
68}
69
70func TestSizeValid(t *testing.T) {
71	tests := []struct {
72		name string
73		sz   Size
74		want bool
75	}{
76		{"positive", Size{Cols: 80, Rows: 24}, true},
77		{"zero cols", Size{Cols: 0, Rows: 24}, false},
78		{"zero rows", Size{Cols: 80, Rows: 0}, false},
79		{"zero both", Size{Cols: 0, Rows: 0}, false},
80		{"negative cols", Size{Cols: -1, Rows: 24}, false},
81		{"negative rows", Size{Cols: 80, Rows: -1}, false},
82	}
83
84	for _, tt := range tests {
85		t.Run(tt.name, func(t *testing.T) {
86			if got := tt.sz.Valid(); got != tt.want {
87				t.Errorf("Size%+v.Valid() = %v, want %v", tt.sz, got, tt.want)
88			}
89		})
90	}
91}

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 12

Tags 11

↑↓ moveenter openesc close