MCPcopy
hub / github.com/TanStack/router / setup

Function setup

packages/vue-router/tests/blocker.test.tsx:29–107  ·  view source on GitHub ↗
({ blockerFn, disabled, ignoreBlocker }: BlockerTestOpts)

Source from the content-addressed store, hash-verified

27}
28
29async function setup({ blockerFn, disabled, ignoreBlocker }: BlockerTestOpts) {
30 const _mockBlockerFn = vi.fn(blockerFn)
31 const rootRoute = createRootRoute()
32 const indexRoute = createRoute({
33 getParentRoute: () => rootRoute,
34 path: '/',
35 component: function Setup() {
36 const navigate = useNavigate()
37 useBlocker({ disabled, shouldBlockFn: _mockBlockerFn })
38 return (
39 <>
40 <h1>Index</h1>
41 <Link to="/posts" ignoreBlocker={ignoreBlocker}>
42 link to posts
43 </Link>
44 <Link to="/foo">link to foo</Link>
45 <button onClick={() => navigate({ to: '/posts', ignoreBlocker })}>
46 button
47 </button>
48 </>
49 )
50 },
51 })
52
53 const postsRoute = createRoute({
54 getParentRoute: () => rootRoute,
55 path: '/posts',
56 component: () => (
57 <>
58 <h1>Posts</h1>
59 </>
60 ),
61 })
62
63 const fooRoute = createRoute({
64 getParentRoute: () => rootRoute,
65 path: '/foo',
66 beforeLoad: () => {
67 throw redirect({ to: '/bar' })
68 },
69 component: () => (
70 <>
71 <h1>Foo</h1>
72 </>
73 ),
74 })
75
76 const barRoute = createRoute({
77 getParentRoute: () => rootRoute,
78 path: '/bar',
79 component: () => (
80 <>
81 <h1>Bar</h1>
82 </>
83 ),
84 })
85
86 const router = createRouter({

Callers 1

blocker.test.tsxFile · 0.70

Calls 8

createRootRouteFunction · 0.90
createRouteFunction · 0.90
useNavigateFunction · 0.90
useBlockerFunction · 0.90
redirectFunction · 0.90
createRouterFunction · 0.90
navigateFunction · 0.50
renderFunction · 0.50

Tested by

no test coverage detected