Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
fisker committed May 10, 2024
1 parent 6fde3fe commit 4a23491
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
27 changes: 27 additions & 0 deletions test/snapshots/throw-new-error.mjs.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,3 +534,30 @@ Generated by [AVA](https://avajs.dev).
| ^^^^^^^^^^^^^^^^ Use \`new\` when creating an error.␊
3 | });␊
`

## invalid(26): function foo() { return[globalThis][0].Error('message'); }

> Input
`␊
1 | function foo() {␊
2 | return[globalThis][0].Error('message');␊
3 | }␊
`

> Output
`␊
1 | function foo() {␊
2 | new returnnew [globalThis][0].Error('message');␊
3 | }␊
`

> Error 1/1
`␊
1 | function foo() {␊
> 2 | return[globalThis][0].Error('message');␊
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use \`new\` when creating an error.␊
3 | }␊
`
Binary file modified test/snapshots/throw-new-error.mjs.snap
Binary file not shown.
5 changes: 5 additions & 0 deletions test/throw-new-error.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,10 @@ test.snapshot({
reject(Error('message'));
});
`,
outdent`
function foo() {
return[globalThis][0].Error('message');
}
`
],
});

0 comments on commit 4a23491

Please sign in to comment.