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AAI,EAAE;YACR,MAAM,CAAC,qBAAM,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;SAC/C;IACH,CAAC;IACD,qEAAqE;IACrE,SAAS;QACP,OAAO,uBAAM,CAAC,SAAS,EAAE,CAAC;IAC5B,CAAC;IACD,wEAAwE;IACxE,SAAS,CAAC,MAA+B,EAAE,IAAa;QACtD,uBAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QACzB,IAAI,IAAI,EAAE;YACR,MAAM,CAAC,qBAAM,CAAC,CAAC,wBAAwB,CAAC,IAAI,CAAC,CAAC;SAC/C;IACH,CAAC;IACD,qEAAqE;IACrE,UAAU;QACR,IAAA,kBAAG,EAAC,GAAG,EAAE,CAAC,uBAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACjC,CAAC;CACF,CAAC","sourcesContent":["/// <reference types=\"../../types/jest\" />\nimport './expect';\n\nimport { act, render, RenderResult, screen } from '@testing-library/react-native';\nimport React from 'react';\n\nimport { MockContextConfig, getMockConfig, getMockContext } from './mock-config';\nimport { setInitialUrl } from './mocks';\nimport { ExpoRoot } from '../ExpoRoot';\nimport getPathFromState from '../fork/getPathFromState';\nimport { stateCache } from '../getLinkingConfig';\nimport { store } from '../global-state/router-store';\nimport { router } from '../imperative-api';\n\n// re-export everything\nexport * from '@testing-library/react-native';\n\ntype RenderRouterOptions = Parameters<typeof render>[1] & {\n initialUrl?: any;\n};\n\ntype Result = ReturnType<typeof render> & {\n getPathname(): string;\n getPathnameWithParams(): string;\n getSegments(): string[];\n getSearchParams(): Record<string, string | string[]>;\n};\n\nexport { MockContextConfig, getMockConfig, getMockContext };\n\nexport function renderRouter(\n context: MockContextConfig = './app',\n { initialUrl = '/', ...options }: RenderRouterOptions = {}\n): Result {\n const mockContext = getMockContext(context);\n\n // Reset the initial URL\n setInitialUrl(initialUrl);\n\n // Force the render to be synchronous\n process.env.EXPO_ROUTER_IMPORT_MODE = 'sync';\n stateCache.clear();\n\n let location: URL | undefined;\n\n if (typeof initialUrl === 'string') {\n location = new URL(initialUrl, 'test://');\n } else if (initialUrl instanceof URL) {\n location = initialUrl;\n }\n\n const result = render(<ExpoRoot context={mockContext} location={location} />, {\n ...options,\n });\n\n return Object.assign(result, {\n getPathname(this: RenderResult): string {\n return store.routeInfoSnapshot().pathname;\n },\n getSegments(this: RenderResult): string[] {\n return store.routeInfoSnapshot().segments;\n },\n getSearchParams(this: RenderResult): Record<string, string | string[]> {\n return store.routeInfoSnapshot().params;\n },\n getPathnameWithParams(this: RenderResult): string {\n return getPathFromState(store.rootState!, store.linking!.config);\n },\n });\n}\n\nexport const testRouter = {\n /** Navigate to the provided pathname and the pathname */\n navigate(path: string) {\n act(() => router.navigate(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Push the provided pathname and assert the pathname */\n push(path: string) {\n act(() => router.push(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Replace with provided pathname and assert the pathname */\n replace(path: string) {\n act(() => router.replace(path));\n expect(screen).toHavePathnameWithParams(path);\n },\n /** Go back in history and asset the new pathname */\n back(path?: string) {\n expect(router.canGoBack()).toBe(true);\n act(() => router.back());\n if (path) {\n expect(screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n canGoBack() {\n return router.canGoBack();\n },\n /** Update the current route query params and assert the new pathname */\n setParams(params?: Record<string, string>, path?: string) {\n router.setParams(params);\n if (path) {\n expect(screen).toHavePathnameWithParams(path);\n }\n },\n /** If there's history that supports invoking the `back` function. */\n dismissAll() {\n act(() => router.dismissAll());\n },\n};\n"]}