import { decodeOffsetCursor, encodeOffsetCursor } from './cursor.util';

describe('cursor util', () => {
  it('encodes and decodes cursor offsets', () => {
    const cursor = encodeOffsetCursor(40);
    expect(decodeOffsetCursor(cursor)).toBe(40);
  });

  it('returns null on invalid cursor', () => {
    expect(decodeOffsetCursor('%%%invalid%%%')).toBeNull();
    expect(decodeOffsetCursor(encodeOffsetCursor(-1))).toBeNull();
  });
});
