-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Expand file tree
/
Copy pathconfig-platform.test.ts
More file actions
112 lines (100 loc) · 3.61 KB
/
Copy pathconfig-platform.test.ts
File metadata and controls
112 lines (100 loc) · 3.61 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import test from 'ava';
import {resolvePlatformConfig} from '../../app/utils/resolve-platform-config';
const baseConfig = () => ({
shell: '/bin/sh',
shellArgs: ['--login'],
env: {BASE: '1'},
updateChannel: 'stable' as const,
autoUpdatePlugins: true,
defaultSSHApp: true,
disableAutoUpdates: false,
useConpty: undefined,
backgroundColor: '#000',
bell: 'SOUND' as const,
bellSound: null,
bellSoundURL: null,
borderColor: '#333',
colors: {} as any,
copyOnSelect: false,
css: '',
cursorAccentColor: '#000',
cursorBlink: false,
cursorColor: '#fff',
cursorShape: 'BLOCK' as const,
disableLigatures: true,
fontFamily: 'monospace',
fontSize: 12,
fontWeight: 'normal' as const,
fontWeightBold: 'bold' as const,
foregroundColor: '#fff',
imageSupport: false,
letterSpacing: 0,
lineHeight: 1,
macOptionSelectionMode: 'vertical',
padding: '12px',
preserveCWD: true,
quickEdit: false,
screenReaderMode: false,
scrollback: 1000,
selectionColor: 'rgba(0,0,0,0.3)',
showHamburgerMenu: '' as const,
showWindowControls: '' as const,
termCSS: '',
webGLRenderer: false,
webLinksActivationKey: '' as const,
workingDirectory: '',
defaultProfile: 'default',
profiles: []
});
test('resolvePlatformConfig: linux uses shellLinux', (t) => {
const cfg = {...baseConfig(), shellLinux: '/bin/bash'};
const result = resolvePlatformConfig(cfg, 'linux');
t.is(result.shell, '/bin/bash');
});
test('resolvePlatformConfig: darwin uses shellOsx', (t) => {
const cfg = {...baseConfig(), shellOsx: '/bin/zsh'};
const result = resolvePlatformConfig(cfg, 'darwin');
t.is(result.shell, '/bin/zsh');
});
test('resolvePlatformConfig: win32 uses shellWindows', (t) => {
const cfg = {...baseConfig(), shellWindows: 'C:\\Windows\\System32\\cmd.exe'};
const result = resolvePlatformConfig(cfg, 'win32');
t.is(result.shell, 'C:\\Windows\\System32\\cmd.exe');
});
test('resolvePlatformConfig: shellArgsLinux overrides shellArgs', (t) => {
const cfg = {...baseConfig(), shellArgsLinux: ['-i']};
const result = resolvePlatformConfig(cfg, 'linux');
t.deepEqual(result.shellArgs, ['-i']);
});
test('resolvePlatformConfig: empty shellArgsWindows overrides shellArgs', (t) => {
const cfg = {...baseConfig(), shellArgsWindows: []};
const result = resolvePlatformConfig(cfg, 'win32');
t.deepEqual(result.shellArgs, []);
});
test('resolvePlatformConfig: envLinux is merged with env', (t) => {
const cfg = {...baseConfig(), env: {BASE: '1', SHARED: 'x'}, envLinux: {LINUX_ONLY: 'y', SHARED: 'z'}};
const result = resolvePlatformConfig(cfg, 'linux');
t.deepEqual(result.env, {BASE: '1', SHARED: 'z', LINUX_ONLY: 'y'});
});
test('resolvePlatformConfig: envOsx does not affect linux', (t) => {
const cfg = {...baseConfig(), envOsx: {MAC_ONLY: '1'}};
const result = resolvePlatformConfig(cfg, 'linux');
t.is(result.env['MAC_ONLY'], undefined);
});
test('resolvePlatformConfig: no platform-specific keys leaves config unchanged', (t) => {
const cfg = baseConfig();
const result = resolvePlatformConfig(cfg, 'linux');
t.is(result.shell, '/bin/sh');
t.deepEqual(result.shellArgs, ['--login']);
t.deepEqual(result.env, {BASE: '1'});
});
test('resolvePlatformConfig: unsupported platform returns config unchanged', (t) => {
const cfg = {...baseConfig(), shellLinux: '/bin/bash'};
const result = resolvePlatformConfig(cfg, 'freebsd' as NodeJS.Platform);
t.is(result.shell, '/bin/sh');
});
test('resolvePlatformConfig: empty string shellWindows still overrides shell', (t) => {
const cfg = {...baseConfig(), shellWindows: ''};
const result = resolvePlatformConfig(cfg, 'win32');
t.is(result.shell, '');
});