-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathgetGitConfig.test.ts
More file actions
76 lines (71 loc) · 1.9 KB
/
getGitConfig.test.ts
File metadata and controls
76 lines (71 loc) · 1.9 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
69
70
71
72
73
74
75
76
import {
DEFAULT_MIN_LINE_WIDTH,
DEFAULT_THEME_DIRECTORY,
DEFAULT_THEME_NAME,
DEFAULT_TREE_WIDTH,
GitConfig,
getGitConfig,
} from './getGitConfig';
const DEFAULT_CONFIG: GitConfig = {
WRAP_LINES: true,
HIGHLIGHT_LINE_CHANGES: true,
MIN_LINE_WIDTH: DEFAULT_MIN_LINE_WIDTH,
THEME_NAME: DEFAULT_THEME_NAME,
THEME_DIRECTORY: DEFAULT_THEME_DIRECTORY,
INTERACTIVE: false,
TREE_WIDTH: DEFAULT_TREE_WIDTH,
};
describe('getGitConfig', () => {
test('empty', () => {
expect(getGitConfig('')).toEqual(DEFAULT_CONFIG);
});
test('full', () => {
expect(
getGitConfig(`
split-diffs.wrap-lines=false
split-diffs.highlight-line-changes=false
split-diffs.min-line-width=40
split-diffs.theme-name=arctic
split-diffs.theme-directory=/tmp
split-diffs.syntax-highlighting-theme=dark-plus
split-diffs.tree-width=40
`)
).toEqual({
WRAP_LINES: false,
HIGHLIGHT_LINE_CHANGES: false,
MIN_LINE_WIDTH: 40,
THEME_NAME: 'arctic',
THEME_DIRECTORY: '/tmp',
SYNTAX_HIGHLIGHTING_THEME: 'dark-plus',
INTERACTIVE: false,
TREE_WIDTH: 40,
});
});
test('partial', () => {
expect(
getGitConfig(`
split-diffs.wrap-lines=true
split-diffs.syntax-highlighting-theme=nord
`)
).toEqual({
...DEFAULT_CONFIG,
WRAP_LINES: true,
SYNTAX_HIGHLIGHTING_THEME: 'nord',
});
});
test('invalid values', () => {
expect(
getGitConfig(`
split-diffs.wrap-lines=1
split-diffs.highlight-line-changes=1
split-diffs.min-line-width=bar
split-diffs.syntax-highlighting-theme=foo
split-diffs.theme-name=baz
`)
).toEqual({
...DEFAULT_CONFIG,
SYNTAX_HIGHLIGHTING_THEME: 'foo',
THEME_NAME: 'baz',
});
});
});