24 lines
744 B
TypeScript
24 lines
744 B
TypeScript
import { decode, encode } from './local-operations-cursor.codec';
|
|
|
|
const secret = 'secret';
|
|
const cursor = {
|
|
accountId: 'account',
|
|
at: '2026-01-01T00:00:00.000Z',
|
|
binding: 'owner-filter-binding',
|
|
id: 'operation',
|
|
movingEnd: false,
|
|
to: '2026-02-01T00:00:00.000Z',
|
|
};
|
|
|
|
describe('local operations cursor', () => {
|
|
it('roundtrips the opaque cursor, including its owner and filter binding', () => {
|
|
expect(decode(encode(cursor, secret), secret)).toEqual(cursor);
|
|
});
|
|
|
|
it('rejects a tampered cursor and a cursor signed with a different key', () => {
|
|
const encoded = encode(cursor, secret);
|
|
expect(() => decode(`${encoded}x`, secret)).toThrow();
|
|
expect(() => decode(encoded, 'different-secret')).toThrow();
|
|
});
|
|
});
|