Skip to content

Commit

Permalink
fix(fixer): remove space from replaced text in fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
neriyarden authored and MichaelDeBoey committed Oct 17, 2024
1 parent 72d0a89 commit c5c9ea7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/rules/no-await-sync-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default createTestingLibraryRule<Options, MessageIds>({
},
fix: (fixer) => {
const awaitRangeStart = awaitExpression.range[0];
const awaitRangeEnd = awaitExpression.range[0] + 'await '.length;
const awaitRangeEnd = awaitExpression.range[0] + 'await'.length;

return fixer.replaceTextRange(
[awaitRangeStart, awaitRangeEnd],
Expand Down
21 changes: 11 additions & 10 deletions tests/lib/rules/no-await-sync-queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ ruleTester.run(RULE_NAME, rule, {
},
],
output: `async () => {
const element = ${query}('foo')
const element = ${query}('foo')
}
`,
} as const)
Expand All @@ -158,6 +158,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: 'noAwaitSyncQuery', line: 3, column: 31 }],
output: `
async () => {
const element = getByIcon('search')
const element = getByIcon('search')
}
`,
Expand All @@ -171,7 +172,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: 'noAwaitSyncQuery', line: 3, column: 31 }],
output: `
async () => {
const element = queryByIcon('search')
const element = queryByIcon('search')
}
`,
},
Expand All @@ -184,7 +185,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: 'noAwaitSyncQuery', line: 3, column: 38 }],
output: `
async () => {
const element = screen.getAllByIcon('search')
const element = screen.getAllByIcon('search')
}
`,
},
Expand All @@ -197,7 +198,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: 'noAwaitSyncQuery', line: 3, column: 38 }],
output: `
async () => {
const element = screen.queryAllByIcon('search')
const element = screen.queryAllByIcon('search')
}
`,
},
Expand All @@ -217,7 +218,7 @@ ruleTester.run(RULE_NAME, rule, {
},
],
output: `async () => {
expect(${query}('foo')).toBeEnabled()
expect( ${query}('foo')).toBeEnabled()
}
`,
} as const)
Expand All @@ -239,7 +240,7 @@ ruleTester.run(RULE_NAME, rule, {
},
],
output: `async () => {
const element = screen.${query}('foo')
const element = screen.${query}('foo')
}
`,
} as const)
Expand All @@ -261,7 +262,7 @@ ruleTester.run(RULE_NAME, rule, {
},
],
output: `async () => {
expect(screen.${query}('foo')).toBeEnabled()
expect( screen.${query}('foo')).toBeEnabled()
}
`,
} as const)
Expand All @@ -283,7 +284,7 @@ ruleTester.run(RULE_NAME, rule, {
output: `
import { screen } from '${testingFramework}'
() => {
const element = screen.getByRole('button')
const element = screen.getByRole('button')
}
`,
} as const)
Expand All @@ -301,7 +302,7 @@ ruleTester.run(RULE_NAME, rule, {
output: `
import { screen } from 'test-utils'
() => {
const element = screen.getByRole('button')
const element = screen.getByRole('button')
}
`,
},
Expand All @@ -319,7 +320,7 @@ ruleTester.run(RULE_NAME, rule, {
errors: [{ messageId: 'noAwaitSyncQuery', line: 3, column: 31 }],
output: `
test('A valid example test', async () => {
const element = queryByIcon('search')
const element = queryByIcon('search')
})
`,
},
Expand Down

0 comments on commit c5c9ea7

Please sign in to comment.