Repository navigation
Conversation
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.
There was a problem hiding this comment.
🟡 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
mustDasherizeinto 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)
| }) | ||
|
|
||
| it('throws a SyntaxError when the name has no dash', () => { | ||
| expect(() => mustDasherize('json')).to.throw(DOMException, 'property: json is not a valid property name') |
Author
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Hi! Small test-coverage addition for
src/dasherize.ts.mustDasherizeis the guard behind@attrand@controllername validation, but it had no tests of its own — onlydasherizewas covered. This adds amustDasherizeblock totest/dasherize.tscovering:typeargument,SyntaxErrorthrown 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 --noEmitpluseslintpass. I could not runnpm testlocally because no usable Chrome is available in this environment (web-test-runner needs one), so the browser suite will need CI to confirm.