Testing Sync Store Compression Hook Implementation in Insomnia
This test suite validates the compression hook functionality in Insomnia’s sync store system. It covers both compression and decompression operations for different data types and file extensions, ensuring reliable data transformation during sync operations.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
kong/insomnia
packages/insomnia/src/sync/store/hooks/__tests__/compress.test.ts
import { describe, expect, it } from 'vitest';
import hook from '../compress';
describe('compress hook', () => {
it('compresses non-extension keys', async () => {
const compressed = await hook.write('', 'hello');
const uncompressed = await hook.read('', compressed);
expect(uncompressed.toString()).toBe('hello');
});
it('writes raw data for extensions', async () => {
const compressed = await hook.write('.json', 'hello');
expect(compressed.toString('base64')).toBe('hello');
});
it('reads compressed data', async () => {
const data = Buffer.from('hello', 'utf8');
const compressed = await hook.read('.json', data);
expect(compressed.toString('utf8')).toBe('hello');
});
});