Skip to content

Commit

Permalink
fix: skip not needed broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
MounirDhahri committed Nov 8, 2024
1 parent 7cdd53e commit 834e38b
Showing 1 changed file with 9 additions and 22 deletions.
31 changes: 9 additions & 22 deletions src/app/utils/hooks/useBackHandler.tests.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { renderHook } from "@testing-library/react-hooks"
import { BackHandler } from "react-native"
import { useBackHandler, useAndroidGoBack } from "./useBackHandler"
import { useBackHandler } from "./useBackHandler"

jest.mock("react-native", () => ({
BackHandler: {
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
},
Platform: {
OS: "ios",
},
NativeModules: {
ArtsyNativeModule: {
gitCommitShortHash: "1234567",
},
},
}))

describe("useBackHandler Hooks", () => {
Expand Down Expand Up @@ -60,25 +68,4 @@ describe("useBackHandler Hooks", () => {
expect(removeEventListenerMock).toBeCalledWith("hardwareBackPress", handler)
})
})

describe("useAndroidGoBack", () => {
it("should add back press listener on screen mount", () => {
renderHook(() => useAndroidGoBack())

expect(addEventListenerMock).toHaveBeenCalledTimes(1)
expect(removeEventListenerMock).toHaveBeenCalledTimes(0)
})

it("should remove back press listener on screen unmount", () => {
const { unmount } = renderHook(() => useAndroidGoBack())

expect(addEventListenerMock).toHaveBeenCalledTimes(1)
expect(removeEventListenerMock).toHaveBeenCalledTimes(0)

unmount()

expect(addEventListenerMock).toHaveBeenCalledTimes(1)
expect(removeEventListenerMock).toHaveBeenCalledTimes(1)
})
})
})

0 comments on commit 834e38b

Please sign in to comment.