compression-unprofitable.spec.ts 799 B

12345678910111213141516171819202122232425
  1. import { describe, expect, it, vi } from 'vitest'
  2. import type { SessionEvent } from '@deepseek-ai/dsh-session'
  3. vi.mock('node:zlib', async (importOriginal) => {
  4. const actual = await importOriginal<typeof import('node:zlib')>()
  5. return {
  6. ...actual,
  7. zstdCompressSync: (input: ArrayBufferView) => Buffer.alloc(input.byteLength + 1),
  8. }
  9. })
  10. import { bindRecord, ZSTD_DATA_THRESHOLD_BYTES } from '../src/compression.ts'
  11. describe('SQLite compression fallback', () => {
  12. it('keeps large data as text when its Zstandard frame is not smaller', () => {
  13. const event = {
  14. type: 'assistant/message',
  15. seq: 0,
  16. time: 1,
  17. data: { text: 'x'.repeat(ZSTD_DATA_THRESHOLD_BYTES) },
  18. } as unknown as SessionEvent
  19. expect(typeof bindRecord(event).data).toBe('string')
  20. })
  21. })