-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathpreview-context.test.sh
More file actions
68 lines (52 loc) · 1.77 KB
/
preview-context.test.sh
File metadata and controls
68 lines (52 loc) · 1.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env bash
function set_up_before_script() {
source bin/git-forgit
FORGIT="bin/git-forgit"
# Ignore global git config files
export GIT_CONFIG_SYSTEM=/dev/null
export GIT_CONFIG_GLOBAL=/dev/null
cd "$(bashunit::temp_dir)" || return 1
git init --quiet
git config user.name "Test User"
git config user.email "test@example.com"
touch tracked.txt
git add tracked.txt
git commit -m "init" --quiet
}
function test_forgit_pager_uses_preview_pager_only_in_explicit_preview_context() {
local without_marker with_marker
without_marker=$(
FORGIT_DIFF_PAGER="printf diff" \
FORGIT_PREVIEW_PAGER="printf preview" \
FZF_PREVIEW_COLUMNS=80 \
_forgit_pager diff
)
with_marker=$(
FORGIT_DIFF_PAGER="printf diff" \
FORGIT_PREVIEW_PAGER="printf preview" \
FORGIT_IN_PREVIEW=1 \
_forgit_pager diff
)
assert_same "diff" "$without_marker"
assert_same "preview" "$with_marker"
}
function _forgit_capture_preview_flag() {
printf '%s' "${FORGIT_IN_PREVIEW:-unset}"
}
function test_forgit_preview_wrapper_marks_preview_context() {
local actual
actual=$(_forgit_preview capture_preview_flag 2>/dev/null || true)
assert_same "1" "$actual"
}
function test_forgit_diff_preview_command_uses_preview_wrapper() {
bashunit::mock "fzf" 'printf "%s" "$FZF_DEFAULT_OPTS"'
local output
output=$(_forgit_diff)
assert_contains "--preview=\"$FORGIT preview diff_view {}" "$output"
}
function test_forgit_show_preview_command_uses_preview_wrapper() {
bashunit::mock "fzf" 'printf "%s" "$FZF_DEFAULT_OPTS"'
local output
output=$(_forgit_show HEAD)
assert_contains "--preview=\"$FORGIT preview show_preview {}" "$output"
}