Skip to content

Commit

Permalink
fire focus and blur events correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
oielbanna committed Dec 13, 2020
1 parent 283dd35 commit df82b01
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion jest.setup.tsx
@@ -1,7 +1,7 @@
import "jest-dom/extend-expect"
// Get fireEvent from the native testing library
// because @testing-library/react one switches out mouseEnter and mouseLeave
import { fireEvent } from "@testing-library/dom"
import { fireEvent, getByTestId } from "@testing-library/dom"
import { render as testRender, act } from "@testing-library/react"
import * as React from "react"

Expand All @@ -25,6 +25,14 @@ export const mouseUp = (element: Element) =>
act(() => {
fireEvent.mouseUp(element)
})
export const focus = (element: HTMLElement, testId: string) =>
act(() => {
getByTestId(element, testId).focus()
})
export const blur = (element: HTMLElement, testId: string) =>
act(() => {
getByTestId(element, testId).blur()
})

export const render = (children: any) => {
const renderReturn = testRender(
Expand Down

0 comments on commit df82b01

Please sign in to comment.