v0.33.0 62a09f5

zoom_test.go RawHistoryFolder

1package entity
2
3import (
4	"math"
5	"testing"
6)
7
8func TestZoomPercentageRoundsDisplayedValue(t *testing.T) {
9	tests := []struct {
10		name   string
11		factor float64
12		want   int
13	}{
14		{name: "default_zoom", factor: 1.0, want: 100},
15		{name: "accumulated_default_error", factor: 0.9999999999999997, want: 100},
16		{name: "accumulated_above_default", factor: 1.0000000000000002, want: 100},
17		{name: "ordinary_percent", factor: 1.5, want: 150},
18		{name: "minimum_zoom", factor: ZoomMin, want: 25},
19		{name: "maximum_zoom", factor: ZoomMax, want: 500},
20		{name: "rounds_up", factor: 1.006, want: 101},
21		{name: "rounds_down", factor: 1.004, want: 100},
22		{name: "three_digit_percent_below_half", factor: 2.344, want: 234},
23	}
24
25	for _, tt := range tests {
26		t.Run(tt.name, func(t *testing.T) {
27			zoom := NewZoomLevel("example.com", tt.factor)
28			if got := zoom.Percentage(); got != tt.want {
29				t.Fatalf("Percentage()=%d, want %d for factor %.16f", got, tt.want, tt.factor)
30			}
31		})
32	}
33}
34
35func TestZoomPercentageSurvivesRepeatedSteps(t *testing.T) {
36	zoom := NewZoomLevel("example.com", ZoomDefault)
37
38	for range 10 {
39		zoom.ZoomIn()
40	}
41	if got := zoom.Percentage(); got != 200 {
42		t.Fatalf("after 10 zoom-in steps Percentage()=%d, want 200", got)
43	}
44
45	for range 10 {
46		zoom.ZoomOut()
47	}
48	if got := zoom.Percentage(); got != 100 {
49		t.Fatalf("after 10 zoom-out steps Percentage()=%d, want 100", got)
50	}
51	if math.Abs(zoom.ZoomFactor-ZoomDefault) > 1e-9 {
52		t.Fatalf("persisted factor drifted to %.16f, want default", zoom.ZoomFactor)
53	}
54	if !zoom.IsDefault() {
55		t.Fatal("factor behind a 100%% display must still compare equal to the default zoom")
56	}
57}

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 8

Tags 42

↑↓ moveenter openesc close