Skip to content

Commit

Permalink
fix(expect-expect): include numbers when matching assert function nam…
Browse files Browse the repository at this point in the history
…es with wildcards (#1134)
  • Loading branch information
G-Rath authored May 29, 2022
1 parent a19bcf4 commit 2d0ef11
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/rules/__tests__/expect-expect.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ ruleTester.run('expect-expect', rule, {

ruleTester.run('wildcards', rule, {
valid: [
{
code: "test('should pass *', () => expect404ToBeLoaded());",
options: [{ assertFunctionNames: ['expect*'] }],
},
{
code: "test('should pass *', () => expect.toHaveStatus404());",
options: [{ assertFunctionNames: ['expect.**'] }],
},
{
code: "test('should pass', () => tester.foo().expect(123));",
options: [{ assertFunctionNames: ['tester.*.expect'] }],
Expand Down
4 changes: 2 additions & 2 deletions src/rules/expect-expect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ function matchesAssertFunctionName(
`^${p
.split('.')
.map(x => {
if (x === '**') return '[a-z\\.]*';
if (x === '**') return '[a-z\\d\\.]*';
return x.replace(/\*/gu, '[a-z]*');
return x.replace(/\*/gu, '[a-z\\d]*');
})
.join('\\.')}(\\.|$)`,
'ui',
Expand Down

0 comments on commit 2d0ef11

Please sign in to comment.