Skip to content

test(dasherize): cover mustDasherize success and error paths - #375

Open
Ultroncn wants to merge 2 commits into
github:mainfrom
Ultroncn:test/must-dasherize
Open

Ultroncn wants to merge 2 commits into
github:mainfrom
Ultroncn:test/must-dasherize

Conversation

@Ultroncn

Copy link
Copy Markdown

Hi! Small test-coverage addition for src/dasherize.ts.

mustDasherize is the guard behind @attr and @controller name validation, but it had no tests of its own — only dasherize was covered. This adds a mustDasherize block to test/dasherize.ts covering:

  • the happy path (returns the dasherized name),
  • the custom type argument,
  • the SyntaxError thrown when the dasherized name contains no dash, including the error message naming the type.

Verified the four assertions against the implementation in Node, and tsc --noEmit plus eslint pass. I could not run npm test locally because no usable Chrome is available in this environment (web-test-runner needs one), so the browser suite will need CI to confirm.

mustDasherize is the guard behind @attr and @controller name
validation, but it had no tests of its own. Add coverage for the
happy path (returns the dasherized name), the custom type argument,
and the SyntaxError thrown when the dasherized name contains no dash,
including the error message naming the type.
@Ultroncn
Ultroncn requested a review from a team as a code owner November 16, 2026 21:59
Copilot AI adaptive review requested due to automatic review settings November 16, 2026 21:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The test is incomplete because its assertion checks only the exception type and message, allowing a DOMException with the wrong name to pass.

1 open issue
What changed in this PR

Adds focused tests for mustDasherize, covering successful dasherization, custom type handling, and invalid-name errors.

Changes:

  • Imports mustDasherize into the dasherization test suite.
  • Covers successful default and custom-type calls.
  • Covers invalid names, error types, and custom error messages.
File Description
test/​dasherize.ts Adds success- and error-path tests for mustDasherize, including custom types and invalid-name handling.

Review effort: Lite (adaptive)

Comment thread test/dasherize.ts Outdated
})

it('throws a SyntaxError when the name has no dash', () => {
expect(() => mustDasherize('json')).to.throw(DOMException, 'property: json is not a valid property name')

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current tests do not explicitly assert the DOMException's name. I propose adding an explicit name === 'SyntaxError' assertion to both invalid-name cases while keeping the constructor and message checks. This would be test-only, with no production change. Could a maintainer confirm this follow-up scope before I revise the PR?

Chai's to.throw(DOMException, message) only verifies the constructor
and message, so a DOMException created with its default name would
still pass. Capture the thrown error and assert its name is
SyntaxError as well, keeping the instanceof and message checks.

This branch has not been deployed

No deployments
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