summaryrefslogtreecommitdiff
path: root/packages/core/src/utils/editor.test.ts
diff options
context:
space:
mode:
authorEddie Santos <[email protected]>2025-06-09 16:01:06 -0700
committerGitHub <[email protected]>2025-06-09 16:01:06 -0700
commit6484dc9008448637ebdebd21f83d876aaac127c8 (patch)
tree2787f9d14a35ae8ac1a545034ffc472cb2352684 /packages/core/src/utils/editor.test.ts
parent5c9e526f0e967afe75c4948e4b077db286f626f2 (diff)
Add Windsurf in edit tool to modify changes, if installed (#853)
Diffstat (limited to 'packages/core/src/utils/editor.test.ts')
-rw-r--r--packages/core/src/utils/editor.test.ts32
1 files changed, 31 insertions, 1 deletions
diff --git a/packages/core/src/utils/editor.test.ts b/packages/core/src/utils/editor.test.ts
index 20917c0f..e7c2f55a 100644
--- a/packages/core/src/utils/editor.test.ts
+++ b/packages/core/src/utils/editor.test.ts
@@ -35,6 +35,36 @@ describe('checkHasEditor', () => {
expect(checkHasEditor('vscode')).toBe(false);
});
+ it('should return true for windsurf if "windsurf" command exists', () => {
+ (execSync as Mock).mockReturnValue(Buffer.from('/usr/bin/windsurf'));
+ expect(checkHasEditor('windsurf')).toBe(true);
+ expect(execSync).toHaveBeenCalledWith('command -v windsurf', {
+ stdio: 'ignore',
+ });
+ });
+
+ it('should return false for windsurf if "windsurf" command does not exist', () => {
+ (execSync as Mock).mockImplementation(() => {
+ throw new Error();
+ });
+ expect(checkHasEditor('windsurf')).toBe(false);
+ });
+
+ it('should return true for cursor if "cursor" command exists', () => {
+ (execSync as Mock).mockReturnValue(Buffer.from('/usr/bin/cursor'));
+ expect(checkHasEditor('cursor')).toBe(true);
+ expect(execSync).toHaveBeenCalledWith('command -v cursor', {
+ stdio: 'ignore',
+ });
+ });
+
+ it('should return false for cursor if "cursor" command does not exist', () => {
+ (execSync as Mock).mockImplementation(() => {
+ throw new Error();
+ });
+ expect(checkHasEditor('cursor')).toBe(false);
+ });
+
it('should return true for vim if "vim" command exists', () => {
(execSync as Mock).mockReturnValue(Buffer.from('/usr/bin/vim'));
expect(checkHasEditor('vim')).toBe(true);
@@ -71,7 +101,7 @@ describe('getDiffCommand', () => {
it('should return null for an unsupported editor', () => {
// @ts-expect-error Testing unsupported editor
- const command = getDiffCommand('old.txt', 'new.txt', 'nano');
+ const command = getDiffCommand('old.txt', 'new.txt', 'foobar');
expect(command).toBeNull();
});
});