⚡ Zero-dependency plcbundle library exclusively for Bun
1import { describe, test, expect, beforeAll } from 'bun:test';
2import { PLCBundle } from '../src/plcbundle';
3import { TEMP_DIR, createMockIndex, createMockOperations } from './setup';
4
5describe('Integration Tests', () => {
6 let bundle: PLCBundle;
7
8 beforeAll(async () => {
9 bundle = new PLCBundle(TEMP_DIR);
10
11 // Setup complete test environment
12 const mockIndex = createMockIndex();
13 await bundle.saveIndex(mockIndex);
14 });
15
16 test('complete workflow: save, load, query', async () => {
17 // Save index
18 const mockIndex = createMockIndex();
19 await bundle.saveIndex(mockIndex);
20
21 // Load index
22 const loaded = await bundle.loadIndex(true);
23 expect(loaded.bundles.length).toBe(3);
24
25 // Get stats
26 const stats = await bundle.getStats();
27 expect(stats.lastBundle).toBe(3);
28
29 // Get metadata
30 const metadata = await bundle.getMetadata(2);
31 expect(metadata?.bundle_number).toBe(2);
32 });
33
34 test('handles multiple operations sequentially', async () => {
35 const stats1 = await bundle.getStats();
36
37 const mockIndex = createMockIndex();
38 mockIndex.last_bundle = 5;
39 await bundle.saveIndex(mockIndex);
40
41 const stats2 = await bundle.getStats();
42 expect(stats2.lastBundle).toBeGreaterThanOrEqual(stats1.lastBundle);
43 });
44});