Skip to content

Commit d3b30b5

Browse files
committed
tests: add more tests
1 parent 85f99c3 commit d3b30b5

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/features/common/shellDetector.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ function identifyShellFromShellPath(shellPath: string): TerminalShellType {
7474
}
7575

7676
function identifyShellFromTerminalName(terminal: Terminal): TerminalShellType {
77+
if (terminal.name === 'sh') {
78+
// Specifically checking this because other shells have `sh` at the end of their name
79+
// We can match and return bash for this case
80+
return TerminalShellType.bash;
81+
}
7782
return identifyShellFromShellPath(terminal.name);
7883
}
7984

src/test/features/common/shellDetector.unit.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function getShellPath(shellType: string): string | undefined {
8383
case 'nushell':
8484
return '/usr/bin/nu';
8585
case 'tcshell':
86-
return '/usr/bin/tsh';
86+
return '/usr/bin/tcsh';
8787
case 'wsl':
8888
return '/mnt/c/Windows/System32/wsl.exe';
8989
case 'xonsh':
@@ -100,8 +100,9 @@ function expectedShellType(shellType: string): TerminalShellType {
100100
case 'bash':
101101
return TerminalShellType.bash;
102102
case 'powershell':
103-
case 'pwsh':
104103
return TerminalShellType.powershell;
104+
case 'pwsh':
105+
return TerminalShellType.powershellCore;
105106
case 'cmd':
106107
return TerminalShellType.commandPrompt;
107108
case 'gitbash':
@@ -116,6 +117,12 @@ function expectedShellType(shellType: string): TerminalShellType {
116117
return TerminalShellType.cshell;
117118
case 'nushell':
118119
return TerminalShellType.nushell;
120+
case 'tcshell':
121+
return TerminalShellType.tcshell;
122+
case 'wsl':
123+
return TerminalShellType.wsl;
124+
case 'xonsh':
125+
return TerminalShellType.xonsh;
119126
default:
120127
return TerminalShellType.unknown;
121128
}
@@ -138,7 +145,8 @@ suite('Shell Detector', () => {
138145
},
139146
} as Terminal;
140147
const detected = identifyTerminalShell(terminal);
141-
assert.strictEqual(detected, expectedShellType(shellType));
148+
const expected = expectedShellType(shellType);
149+
assert.strictEqual(detected, expected);
142150
});
143151
});
144152
});

0 commit comments

Comments
 (0)