diff options
Diffstat (limited to 'packages/core/src/utils/editor.test.ts')
| -rw-r--r-- | packages/core/src/utils/editor.test.ts | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/packages/core/src/utils/editor.test.ts b/packages/core/src/utils/editor.test.ts index a86d6f59..203223ae 100644 --- a/packages/core/src/utils/editor.test.ts +++ b/packages/core/src/utils/editor.test.ts @@ -70,6 +70,7 @@ describe('editor utils', () => { { editor: 'vim', commands: ['vim'], win32Commands: ['vim'] }, { editor: 'neovim', commands: ['nvim'], win32Commands: ['nvim'] }, { editor: 'zed', commands: ['zed', 'zeditor'], win32Commands: ['zed'] }, + { editor: 'emacs', commands: ['emacs'], win32Commands: ['emacs.exe'] }, ]; for (const { editor, commands, win32Commands } of testCases) { @@ -297,6 +298,14 @@ describe('editor utils', () => { }); } + it('should return the correct command for emacs', () => { + const command = getDiffCommand('old.txt', 'new.txt', 'emacs'); + expect(command).toEqual({ + command: 'emacs', + args: ['--eval', '(ediff "old.txt" "new.txt")'], + }); + }); + it('should return null for an unsupported editor', () => { // @ts-expect-error Testing unsupported editor const command = getDiffCommand('old.txt', 'new.txt', 'foobar'); @@ -372,7 +381,7 @@ describe('editor utils', () => { }); } - const execSyncEditors: EditorType[] = ['vim', 'neovim']; + const execSyncEditors: EditorType[] = ['vim', 'neovim', 'emacs']; for (const editor of execSyncEditors) { it(`should call execSync for ${editor} on non-windows`, async () => { Object.defineProperty(process, 'platform', { value: 'linux' }); @@ -425,6 +434,15 @@ describe('editor utils', () => { expect(allowEditorTypeInSandbox('vim')).toBe(true); }); + it('should allow emacs in sandbox mode', () => { + process.env.SANDBOX = 'sandbox'; + expect(allowEditorTypeInSandbox('emacs')).toBe(true); + }); + + it('should allow emacs when not in sandbox mode', () => { + expect(allowEditorTypeInSandbox('emacs')).toBe(true); + }); + it('should allow neovim in sandbox mode', () => { process.env.SANDBOX = 'sandbox'; expect(allowEditorTypeInSandbox('neovim')).toBe(true); @@ -490,6 +508,12 @@ describe('editor utils', () => { expect(isEditorAvailable('vim')).toBe(true); }); + it('should return true for emacs when installed and in sandbox mode', () => { + (execSync as Mock).mockReturnValue(Buffer.from('/usr/bin/emacs')); + process.env.SANDBOX = 'sandbox'; + expect(isEditorAvailable('emacs')).toBe(true); + }); + it('should return true for neovim when installed and in sandbox mode', () => { (execSync as Mock).mockReturnValue(Buffer.from('/usr/bin/nvim')); process.env.SANDBOX = 'sandbox'; |
