Unit suite · 31 checks

Verify each small primitive.

Unit checks isolate instance state, exact serialization behavior, and the pure helpers that keep playground input and output bounded.

js-message works with bundlers and without a bundler.

Bundlers resolve the bare js-message import normally. Native browser ESM resolves it through a standard import map, with no build or transpilation step.

Message primitives

IDFocused check
UNIT-01A new message starts with an empty type.
UNIT-02Default data objects are independent.
UNIT-03Type and data are the enumerable instance fields.
UNIT-04The JSON getter emits the exact envelope.
UNIT-05The JSON getter excludes local properties.
UNIT-06toJSON() returns only type and data.
UNIT-07JSON.stringify() uses the normalized envelope.
UNIT-08Direct fields retain JSON-safe native values.

Playground source helpers

IDFocused check
UNIT-09The default playground source shows a complete round trip.
UNIT-10Playground root imports resolve to the canonical module.
UNIT-11Playground deep imports resolve to Message.js.
UNIT-12Playground import text outside static declarations is unchanged.
UNIT-13Playground source must be text.
UNIT-14Playground source has a fixed size limit.
UNIT-15Package imports after executable code remain unchanged.
UNIT-16Comments and blank lines may precede package imports.
UNIT-17Other absolute static imports may precede package imports.
UNIT-18Block comments may precede package imports.
UNIT-19Leading package imports may carry trailing line comments.
UNIT-20Compact leading package imports resolve without added whitespace.
UNIT-21Inline block comments may separate the import keyword.
UNIT-22Comment-heavy import preambles remain responsive.
UNIT-23Unicode import-prefix identifiers remain unchanged.
UNIT-24Escaped import-prefix identifiers remain unchanged.

Playground output helpers

IDFocused check
UNIT-25Playground output serializes BigInt.
UNIT-26Playground output serializes undefined.
UNIT-27Playground output serializes errors.
UNIT-28Playground output labels maps.
UNIT-29Playground output labels sets.
UNIT-30Playground output marks circular references.
UNIT-31Playground output truncates primitive strings before transfer.
One concern per row.

Round-trip behavior belongs to the Functional suite; cross-entry agreement belongs to Integration. These Unit checks stay narrow.