Skip to content

Commit

Permalink
refactor: fix ts-expect-error (#873)
Browse files Browse the repository at this point in the history
  • Loading branch information
Belco90 committed Jan 15, 2024
1 parent 93a6ab9 commit 5497dc2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/rules/no-await-sync-events.ts
Expand Up @@ -76,8 +76,8 @@ export default createTestingLibraryRule<Options, MessageIds>({
property.id.name === 'delay' &&
isLiteral(property.init) &&
property.init.value &&
// @ts-expect-error -- TODO: fix me
property.init.value > 0
Number.isInteger(property.init.value) &&
Number(property.init.value) > 0
);
},
AssignmentExpression(node: TSESTree.AssignmentExpression) {
Expand All @@ -89,8 +89,8 @@ export default createTestingLibraryRule<Options, MessageIds>({
isLiteral(node.right) &&
node.right.value !== null
) {
// @ts-expect-error -- TODO: fix me
hasDelayDeclarationOrAssignmentGTZero = node.right.value > 0;
hasDelayDeclarationOrAssignmentGTZero =
Number.isInteger(node.right.value) && Number(node.right.value) > 0;
}
},
'AwaitExpression > CallExpression'(node: TSESTree.CallExpression) {
Expand Down Expand Up @@ -143,8 +143,8 @@ export default createTestingLibraryRule<Options, MessageIds>({
property.key.name === 'delay' &&
isLiteral(property.value) &&
!!property.value.value &&
// @ts-expect-error -- TODO: fix me
property.value.value > 0
Number.isInteger(property.value.value) &&
Number(property.value.value) > 0
);

const simulateEventFunctionName = simulateEventFunctionIdentifier.name;
Expand Down
13 changes: 13 additions & 0 deletions tests/lib/rules/no-await-sync-events.test.ts
Expand Up @@ -142,6 +142,12 @@ ruleTester.run(RULE_NAME, rule, {
code: `() => {
await userEvent.type(element, 'bar', {delay: 1234})
}
`,
},
{
code: `() => {
await userEvent.type(element, 'bar', {delay: null})
}
`,
},
{
Expand All @@ -155,6 +161,13 @@ ruleTester.run(RULE_NAME, rule, {
const delay = 10
await userEvent.keyboard('foo', {delay})
}
`,
},
{
code: `async() => {
const delay = null
await userEvent.keyboard('foo', {delay})
}
`,
},
{
Expand Down

0 comments on commit 5497dc2

Please sign in to comment.