wbxcallprov/test/webexClient.test.js
jmcqueen 6de5392e90
Some checks are pending
CI / verify (push) Waiting to run
Add node:test suite and Gitea Actions CI
- 30-test suite (node --test, no framework) covering the exact functions
  that have regressed in previous rounds:
    * parseStoreArg / parseStoreNumber / storeEmail (helpers)
    * greetingForBrand (brand fallback)
    * formatE911Address / formatSuite (google response reducer)
    * parseNextLink (RFC-5988 pagination — now exported)
    * runStep success / non-critical / critical / no-bot paths
- test/setup.js stubs required env vars so any src/ module can be
  imported cleanly; loaded via --import once per test process
- npm run test wired up; directory form works on Node 20 + 22
- .gitea/workflows/ci.yml runs lint + format:check + test on push/PR
  to main, on Node 22 to match the runtime image
- Exclude test/ and .gitea/ from the Docker build context
- Exclude docker/ from bot Prettier scope (remote-agent is its own
  sub-project with its own tooling)

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 16:07:02 -04:00

39 lines
1.6 KiB
JavaScript

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 = '<https://webexapis.com/v1/people?cursor=abc>; 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 =
'<https://webexapis.com/v1/people?cursor=abc>; rel="next", ' +
'<https://webexapis.com/v1/people?cursor=first>; rel="first"';
assert.equal(parseNextLink(header), 'https://webexapis.com/v1/people?cursor=abc');
});
it('accepts unquoted rel values', () => {
const header = '<https://webexapis.com/v1/people?cursor=xyz>; rel=next';
assert.equal(parseNextLink(header), 'https://webexapis.com/v1/people?cursor=xyz');
});
it('returns null when there is no next rel', () => {
const header =
'<https://webexapis.com/v1/people?cursor=prev>; rel="prev", ' +
'<https://webexapis.com/v1/people?cursor=first>; 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);
});
});