Skip to content

Commit fe38e74

Browse files
committed
test: check-what-ide-use lib (#2)
1 parent 1de8d8b commit fe38e74

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import fs from 'fs';
2+
import checkWhatIdeUse, { IDE_TOOL } from 'lib/check-what-ide-use.ts';
3+
4+
jest.mock('fs');
5+
6+
describe('checkWhatIdeUse', () => {
7+
const mockedExistsSync = fs.existsSync as jest.MockedFunction<typeof fs.existsSync>;
8+
9+
beforeEach(() => {
10+
mockedExistsSync.mockReset();
11+
});
12+
13+
it('returns vscode if .vscode folder exists', () => {
14+
mockedExistsSync.mockImplementation(p => p.toString().endsWith('.vscode'));
15+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.vscode);
16+
});
17+
18+
it('returns cursor if .cursor folder exists', () => {
19+
mockedExistsSync.mockImplementation(p => p.toString().endsWith('.cursor'));
20+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.cursor);
21+
});
22+
23+
it('returns jetbrains if .ide folder exists', () => {
24+
mockedExistsSync.mockImplementation(p => p.toString().endsWith('.ide'));
25+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.jetbrains);
26+
});
27+
28+
it('returns windsurf if .wind folder exists', () => {
29+
mockedExistsSync.mockImplementation(p => p.toString().endsWith('.wind'));
30+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.windsurf);
31+
});
32+
33+
it('returns neovim if .nvim folder exists', () => {
34+
mockedExistsSync.mockImplementation(p => p.toString().endsWith('.nvim'));
35+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.neovim);
36+
});
37+
38+
it('returns vim if .vim folder exists', () => {
39+
mockedExistsSync.mockImplementation(p => p.toString().endsWith('.vim'));
40+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.vim);
41+
});
42+
43+
it('returns emacs if .emacs.d folder exists', () => {
44+
mockedExistsSync.mockImplementation(p => p.toString().endsWith('.emacs.d'));
45+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.emacs);
46+
});
47+
48+
it('returns other if no matching folder exists', () => {
49+
mockedExistsSync.mockReturnValue(false);
50+
expect(checkWhatIdeUse()).toBe(IDE_TOOL.other);
51+
});
52+
});

0 commit comments

Comments
 (0)