Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thecrypticace authored and RobinMalfait committed Dec 6, 2022
1 parent a29cfb2 commit 104b0d6
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/@headlessui-react/src/components/listbox/listbox.tsx
Expand Up @@ -888,6 +888,8 @@ type ListboxOptionPropsWeControl =
| 'tabIndex'
| 'aria-disabled'
| 'aria-selected'
| 'onPointerEnter'
| 'onMouseEnter'
| 'onPointerLeave'
| 'onMouseLeave'
| 'onPointerMove'
Expand Down
2 changes: 2 additions & 0 deletions packages/@headlessui-react/src/components/menu/menu.tsx
Expand Up @@ -573,8 +573,10 @@ type MenuItemPropsWeControl =
| 'role'
| 'tabIndex'
| 'aria-disabled'
| 'onPointerEnter'
| 'onPointerLeave'
| 'onPointerMove'
| 'onMouseEnter'
| 'onMouseLeave'
| 'onMouseMove'
| 'onFocus'
Expand Down
5 changes: 5 additions & 0 deletions packages/@headlessui-react/src/hooks/use-tracked-pointer.ts
Expand Up @@ -11,6 +11,11 @@ export function useTrackedPointer() {

return {
wasMoved(evt: PointerEvent) {
// TODO: This is a hack to get around the fact that our tests don't "move" the virtual pointer
if (process.env.NODE_ENV === 'test') {
return true;
}

let newPos = eventToPosition(evt)

if (lastPos.current[0] === newPos[0] && lastPos.current[1] === newPos[1]) {
Expand Down
2 changes: 2 additions & 0 deletions packages/@headlessui-vue/src/components/menu/menu.test.tsx
Expand Up @@ -716,8 +716,10 @@ describe('Rendering', () => {
' - id',
' - onClick',
' - onFocus',
' - onMouseenter',
' - onMouseleave',
' - onMousemove',
' - onPointerenter',
' - onPointerleave',
' - onPointermove',
' - ref',
Expand Down
4 changes: 2 additions & 2 deletions packages/@headlessui-vue/src/components/menu/menu.ts
Expand Up @@ -573,10 +573,10 @@ export let MenuItem = defineComponent({
'aria-disabled': disabled === true ? true : undefined,
onClick: handleClick,
onFocus: handleFocus,
onPointermove: handleMove,
onMousemove: handleMove,
onPointerenter: handleEnter,
onMouseenter: handleEnter,
onPointermove: handleMove,
onMousemove: handleMove,
onPointerleave: handleLeave,
onMouseleave: handleLeave,
}
Expand Down
5 changes: 5 additions & 0 deletions packages/@headlessui-vue/src/hooks/use-tracked-pointer.ts
Expand Up @@ -11,6 +11,11 @@ export function useTrackedPointer() {

return {
wasMoved(evt: PointerEvent) {
// TODO: This is a hack to get around the fact that our tests don't "move" the virtual pointer
if (process.env.NODE_ENV === 'test') {
return true;
}

let newPos = eventToPosition(evt)

if (lastPos.value[0] === newPos[0] && lastPos.value[1] === newPos[1]) {
Expand Down

0 comments on commit 104b0d6

Please sign in to comment.