d3ro-voice/apps/desktop/tests/main/install-kind.test.ts

43 lines
1.7 KiB
TypeScript

// tests/main/install-kind.test.ts
// 설치 형태 판별 — 휴대용(Scoop·설치 스크립트·zip) 설치본에서 NSIS 자동 업데이터를 켜지 않는다.
import { describe, it, expect } from 'vitest'
import { detectInstallKind, type InstallProbe } from '../../src/main/install-kind'
function probe(overrides: Partial<InstallProbe> = {}): InstallProbe {
return {
platform: 'win32',
exeDirEntries: ['D3RO Voice.exe', 'resources', 'locales'],
hasPortableMarker: false,
portableExecutableDir: undefined,
...overrides,
}
}
describe('detectInstallKind', () => {
it('NSIS 제거 프로그램이 있으면 설치자 소유 디렉터리다', () => {
expect(detectInstallKind(probe({ exeDirEntries: ['D3RO Voice.exe', 'Uninstall D3RO Voice.exe'] }))).toEqual({
kind: 'installer',
reason: 'nsis-uninstaller',
})
})
it('제거 프로그램이 없으면(Scoop/설치 스크립트/zip) 휴대용이다', () => {
expect(detectInstallKind(probe()).kind).toBe('portable')
})
it('휴대용 표식·portable 타깃은 사유만 바꾼다', () => {
expect(detectInstallKind(probe({ hasPortableMarker: true })).reason).toBe('portable-marker')
expect(detectInstallKind(probe({ portableExecutableDir: 'C:\\apps' })).reason).toBe('portable-target')
})
it('표식이 NSIS 설치본에 섞여도 제거 프로그램이 있으면 자동 업데이트를 끄지 않는다', () => {
expect(
detectInstallKind(probe({ hasPortableMarker: true, exeDirEntries: ['Uninstall D3RO Voice.exe'] })).kind,
).toBe('installer')
})
it('macOS 는 설치 형태와 무관하게 업데이터를 쓴다', () => {
expect(detectInstallKind(probe({ platform: 'darwin' })).kind).toBe('installer')
})
})