Skip to content

Add a node:test suite - #67

Merged
iamtraction merged 4 commits into
masterfrom
test/node-test-suite
Aug 5, 2026
Merged

Add a node:test suite#67
iamtraction merged 4 commits into
masterfrom
test/node-test-suite

Conversation

@iamtraction

Copy link
Copy Markdown
Owner

Adds the library's first automated test suite, built on Node's built-in node:test runner — no test framework, no new dependencies.

  • languagesgetCode resolution: codes, names, script-subtag casing, and unknowns
  • request building — query construction, name→code resolution, the repeated dt serialization, and the GET→POST switch, asserted against the request captured off a mocked dispatcher
  • response parsing — the response-array → result transformation, one branch per case, against canned bodies
  • errors — the validation and response-error rejections
  • smoke — one live call to the real endpoint, asserting only that the response still parses into our shape, never its content (that's Google's concern)

Mocked tests run through the public options.dispatcher option, so nothing internal is stubbed. Lint moves to its own npm run lint step, separate from npm test.

Also fixes a latent bug: translate(text, null) threw because typeof null === "object" slipped past the options guard; it now defaults like a missing argument.

🤖 Generated with Claude Code

iamtraction and others added 4 commits August 5, 2026 20:51
typeof null is "object", so a null options slipped past the guard and threw
on options.from. Route it to the default {} like undefined already is.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Cover language resolution, request building, response parsing, and error
handling deterministically through the public options.dispatcher seam, plus
one live smoke test that checks a real response still parses into our shape.
Add the test and test:coverage npm scripts to run it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Split lint out of npm test into a separate npm run lint step, and collapse
the publish workflow to a single lint-gated job.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@iamtraction
iamtraction force-pushed the test/node-test-suite branch from 4d7b5c7 to 821419c Compare August 5, 2026 15:22
@iamtraction
iamtraction merged commit b02e520 into master Aug 5, 2026
2 checks passed
@iamtraction
iamtraction deleted the test/node-test-suite branch August 5, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant