inbox-sync.test.ts (1105B)
1 import { test, expect } from 'vitest'; 2 import { privateInboxQueries } from '../../src/lib/nostr/inbox-queries.ts'; 3 const owner = 'a'.repeat(64); 4 test('live filter requests no retained history and admits future backdated outer events', () => 5 expect(privateInboxQueries(owner, 'live')).toEqual([ 6 { kinds: [1059], '#p': [owner], limit: 0 } 7 ])); 8 test('finite backfill requests the bounded existing 200 without inner time cursor', () => 9 expect(privateInboxQueries(owner, 'backfill')).toEqual([ 10 { kinds: [1059], '#p': [owner], limit: 200 } 11 ])); 12 test('noncanonical owner cannot construct a private query', () => 13 expect(() => privateInboxQueries('not a key', 'live')).toThrow()); 14 test('unknown mode cannot silently make a live or history request', () => 15 expect(() => privateInboxQueries(owner, 'unreviewed' as 'live')).toThrow()); 16 test('query result mutation cannot alter later private filter scope', () => { 17 const a = privateInboxQueries(owner, 'live'); 18 a[0].kinds!.push(14); 19 expect(privateInboxQueries(owner, 'live')).toEqual([ 20 { kinds: [1059], '#p': [owner], limit: 0 } 21 ]); 22 });