Skip to content

test(cyberware-contract-generator-dart): add unit tests - #291

Merged
Komoszek merged 1 commit into
mainfrom
test/cyberware-contract-generator-dart
Jun 25, 2026
Merged

Komoszek merged 1 commit into
mainfrom
test/cyberware-contract-generator-dart

Conversation

@claude

@claude claude Bot commented Jun 25, 2026

Copy link
Copy Markdown

Requested by Sebastian Konowrocki · Slack thread

Before / After

The @leancodepl/cyberware-contract-generator-dart package had no tests. It now has 25 tests across three files covering:

  • config.spec.ts — the Zod config schema: accepts a valid { schema, outputDir }, rejects a missing/non-string outputDir, strips unknown keys, and throws on .parse of an invalid config.
  • loadConfig.spec.ts — resolveOutputDir (absolute paths returned unchanged, relative and parent-relative paths resolved against the config dir) and loadConfig (loads an explicit config path, preserves absolute outputDir, throws on a missing config file, throws on schema-validation failure).
  • generate.spec.ts — the end-to-end Dart generation: writes exactly the three expected files (contract.dart, types.dart, connect_to_host.dart), creates the output dir when missing, reuses an existing one, prints the generation message, and asserts the real rendered Dart output — params extension types with pascal-cased section prefixes, Result typedefs (String vs void), RemoteParams getters, the abstract RemoteMethodsBase signatures, promiseValue/toJS wiring for value-returning remote methods, the JSHostMethods external methods, the connectToHost helper, the do-not-edit banner, and the "not a valid contract root" error path.

How

Tests build real contract schemas with mkZodContractSchema/methodDef from @leancodepl/cyberware-contract, generate into temp dirs, and assert the actual generated Dart source.


Generated by Claude Code

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DXXPnGepYUGie3we1X9PTR
@claude
claude Bot marked this pull request as ready for review June 25, 2026 09:35
@Komoszek
Komoszek merged commit d6e3956 into main Jun 25, 2026
1 check passed
@Komoszek
Komoszek deleted the test/cyberware-contract-generator-dart branch June 25, 2026 12:44
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.

2 participants