libreoffice-engine.spec.ts 1.1 KB

123456789101112131415161718192021222324
  1. import { expect, it } from 'vitest'
  2. import { selectOfficeEngine } from './libreoffice-engine.ts'
  3. it.each([
  4. ['darwin', 'arm64', 'darwin-arm64'], ['darwin', 'x64', 'darwin-x64'],
  5. ['win32', 'arm64', 'win32-arm64'], ['win32', 'x64', 'win32-x64'],
  6. ['linux', 'x64', 'wasm'], ['linux', 'arm64', 'wasm'],
  7. ['darwin', 'other', 'wasm'], ['freebsd', 'x64', 'wasm'],
  8. ])('selects the declared engine for %s/%s', (platform, arch, expected) => {
  9. const optionalDependencies = Object.fromEntries(
  10. ['darwin-arm64', 'darwin-x64', 'win32-arm64', 'win32-x64', 'wasm']
  11. .map(engine => [`@deepseek-ai/libreoffice-kit-${engine}`, '0.0.1']),
  12. )
  13. expect(selectOfficeEngine({ optionalDependencies }, { platform, arch })).toBe(expected)
  14. })
  15. it('selects a declared Linux native target without an OS-specific policy change', () => {
  16. expect(selectOfficeEngine({ optionalDependencies: { '@deepseek-ai/libreoffice-kit-linux-x64': '1' } },
  17. { platform: 'linux', arch: 'x64' })).toBe('linux-x64')
  18. })
  19. it('uses WASM when no native targets are declared', () => {
  20. expect(selectOfficeEngine({}, { platform: 'darwin', arch: 'x64' })).toBe('wasm')
  21. })