diff --git a/docs/rules/prefer-user-event.md b/docs/rules/prefer-user-event.md index 421a0875..d0df0434 100644 --- a/docs/rules/prefer-user-event.md +++ b/docs/rules/prefer-user-event.md @@ -118,6 +118,7 @@ The following table lists all the possible equivalents from the low-level API `f | ---------------- | ----------------------------------------------------------------------------------------------------------- | | `click` | <ul><li>`click`</li><li>`type`</li><li>`selectOptions`</li><li>`deselectOptions`</li></ul> | | `change` | <ul><li>`upload`</li><li>`type`</li><li>`clear`</li><li>`selectOptions`</li><li>`deselectOptions`</li></ul> | +| `changeText` | <ul><li>`type`</li></ul> | | `dblClick` | <ul><li>`dblClick`</li></ul> | | `input` | <ul><li>`type`</li><li>`upload`</li><li>`selectOptions`</li><li>`deselectOptions`</li><li>`paste`</li></ul> | | `keyDown` | <ul><li>`type`</li><li>`tab`</li></ul> | @@ -138,3 +139,5 @@ The following table lists all the possible equivalents from the low-level API `f | `pointerOut` | <ul><li>`unhover`</li></ul> | | `pointerOver` | <ul><li>`hover`</li><li>`selectOptions`</li><li>`deselectOptions`</li></ul> | | `pointerUp` | <ul><li>`click`</li><li>`dblClick`</li><li>`selectOptions`</li><li>`deselectOptions`</li></ul> | +| `press` | <ul><li>`press`</li></ul> | +| `scroll` | <ul><li>`scrollTo`</li></ul> | diff --git a/lib/rules/prefer-user-event.ts b/lib/rules/prefer-user-event.ts index daf408d1..ccfeb435 100644 --- a/lib/rules/prefer-user-event.ts +++ b/lib/rules/prefer-user-event.ts @@ -24,6 +24,8 @@ export const UserEventMethods = [ 'hover', 'unhover', 'paste', + 'press', + 'scrollTo', ] as const; type UserEventMethodsType = (typeof UserEventMethods)[number]; @@ -31,6 +33,7 @@ type UserEventMethodsType = (typeof UserEventMethods)[number]; export const MAPPING_TO_USER_EVENT: Record<string, UserEventMethodsType[]> = { click: ['click', 'type', 'selectOptions', 'deselectOptions'], change: ['upload', 'type', 'clear', 'selectOptions', 'deselectOptions'], + changeText: ['type'], dblClick: ['dblClick'], input: ['type', 'upload', 'selectOptions', 'deselectOptions', 'paste'], keyDown: ['type', 'tab'], @@ -51,6 +54,8 @@ export const MAPPING_TO_USER_EVENT: Record<string, UserEventMethodsType[]> = { pointerOut: ['unhover'], pointerOver: ['hover', 'selectOptions', 'deselectOptions'], pointerUp: ['click', 'dblClick', 'selectOptions', 'deselectOptions'], + press: ['press'], + scroll: ['scrollTo'], }; function buildErrorMessage(fireEventMethod: string) {