mirror of
https://github.com/deepseek-ai/deepseek-harness.git
synced 2026-09-11 04:00:38 +00:00
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { claimDesktopSingleInstance, type DesktopSingleInstanceApplication } from '../src/single-instance.ts'
|
|
|
|
describe('desktop single-instance ownership', () => {
|
|
it('quits a second process without registering lifecycle work', () => {
|
|
const quit = vi.fn()
|
|
const on = vi.fn()
|
|
const application = {
|
|
requestSingleInstanceLock: () => false,
|
|
quit,
|
|
on,
|
|
} satisfies DesktopSingleInstanceApplication
|
|
|
|
expect(claimDesktopSingleInstance(application, vi.fn())).toBe(false)
|
|
expect(quit).toHaveBeenCalledOnce()
|
|
expect(on).not.toHaveBeenCalled()
|
|
})
|
|
|
|
it('routes a later launch to the primary process', () => {
|
|
let secondInstance: (() => void) | undefined
|
|
const focus = vi.fn()
|
|
const application = {
|
|
requestSingleInstanceLock: () => true,
|
|
quit: vi.fn(),
|
|
on: vi.fn((_event: 'second-instance', listener: () => void) => { secondInstance = listener }),
|
|
} satisfies DesktopSingleInstanceApplication
|
|
|
|
expect(claimDesktopSingleInstance(application, focus)).toBe(true)
|
|
secondInstance?.()
|
|
expect(focus).toHaveBeenCalledOnce()
|
|
})
|
|
})
|