test: cover default native command adapter selection
This commit is contained in:
1 parent
e435340eff
commit
5325babc7b
1 file changed
+11
-1
@@ -1,5 +1,6 @@
|
||||
/** File association results and explicit handler authorization at the native command adapter. */
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { describe, expect, it, vi, onTestFinished } from 'vitest'
|
||||
import * as runner from '../src/runner.ts'
|
||||
import { nativeFileApplications, openNativeFileApplication } from '../src/file-applications.ts'
|
||||
|
||||
const application = { id: '/Applications/Music.app', name: 'Music', default: true, icon: null }
|
||||
@@ -35,3 +36,12 @@ describe('native file associations', () => {
|
||||
expect(run).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
it('uses the production command adapter and current platform when no override is supplied', async () => {
|
||||
const run = vi.spyOn(runner, 'runNativeCommand').mockResolvedValue({ stdout: JSON.stringify([application]), stderr: '' })
|
||||
onTestFinished(() => { run.mockRestore() })
|
||||
expect(await nativeFileApplications('/file.mp3', signal)).toEqual(process.platform === 'darwin' ? [application] : [])
|
||||
await openNativeFileApplication('/file.mp3', application.id, signal, { platform: 'darwin' })
|
||||
expect(run).toHaveBeenLastCalledWith('open', ['-a', application.id, '/file.mp3'], signal)
|
||||
})
|
||||
Reference in new issue
Block a user