import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { parseNextLink } from '../src/webex/client.js'; // RFC-5988 Link headers: webexListAll walks these to page through big // list endpoints (locations, users, etc). If this parser breaks silently, // list calls only return the first page. describe('parseNextLink', () => { it('extracts the URL from a next-only Link header', () => { const header = '; rel="next"'; assert.equal(parseNextLink(header), 'https://webexapis.com/v1/people?cursor=abc'); }); it('picks the next rel out of a multi-rel header', () => { const header = '; rel="next", ' + '; rel="first"'; assert.equal(parseNextLink(header), 'https://webexapis.com/v1/people?cursor=abc'); }); it('accepts unquoted rel values', () => { const header = '; rel=next'; assert.equal(parseNextLink(header), 'https://webexapis.com/v1/people?cursor=xyz'); }); it('returns null when there is no next rel', () => { const header = '; rel="prev", ' + '; rel="first"'; assert.equal(parseNextLink(header), null); }); it('returns null for missing / empty headers', () => { assert.equal(parseNextLink(null), null); assert.equal(parseNextLink(undefined), null); assert.equal(parseNextLink(''), null); }); });