Skip to content

Add basic unit tests for EventBuilder and Utils.normalizeUrl #9

Description

@bryanmatthewsimonson

No test harness today. Two small, high-leverage targets to start with:

  1. EventBuilder (src/content/11-event-builder.js) — every event kind the extension emits has a deterministic tag shape. Round-trip each builder against a golden JSON fixture, so accidental changes to tag ordering/casing/kind numbers fail CI instead of polluting relays.

  2. Utils.normalizeUrl — the URL metadata service keys on this. If it silently changes, cached events start missing. A table-driven test with ~20 URL pairs (trailing slash, tracking params, scheme, fragment, IDN, …) would catch nearly all regressions.

Approach

  • Node test runner (node --test) — no dependency to add.
  • Extract the tested modules into something loadable by Node. The content scripts' top-level-var pattern doesn't cooperate with require/import; easiest workaround is a small test/loader.js that reads the file, evals in a sandbox, and returns the declared global. Or switch the modules to a conditional export (if (typeof module === 'object') module.exports = Foo). Pick one approach in the implementing PR and stick to it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Long tailarea/buildCI / packaging / releaseenhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions