Open History to see the last commit
1/* eslint-disable */
2import { describe, it, expect } from 'vitest'
3import {
4 getRouteApi,
5 createFileRoute,
6 createLazyRoute,
7 createLazyFileRoute,
8 LazyRoute,
9 AnyRoute,
10} from '../src'
11β
12describe('createFileRoute has the same hooks as getRouteApi', () => {
13 const routeApi = getRouteApi('foo')
14 const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))
15 // @ts-expect-error
16 const route = createFileRoute('')({})
17β
18 it.each(hookNames.map((name) => [name]))(
19 'should have the "%s" hook defined',
20 (hookName) => {
21 expect(route[hookName as keyof typeof route]).toBeDefined()
22 },
23 )
24})
25β
26describe('createLazyFileRoute has the same hooks as getRouteApi', () => {
27 const routeApi = getRouteApi('foo')
28 const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))
29 // @ts-expect-error
30 const route = createLazyFileRoute('')({})
31β
32 it.each(hookNames.map((name) => [name]))(
33 'should have the "%s" hook defined',
34 (hookName) => {
35 expect(route[hookName as keyof LazyRoute<any>]).toBeDefined()
36 },
37 )
38})
39β
40describe('createLazyRoute has the same hooks as getRouteApi', () => {
41 const routeApi = getRouteApi('foo')
42 const route = createLazyRoute({})({})
43 const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))
44β
45 it.each(hookNames.map((name) => [name]))(
46 'should have the "%s" hook defined',
47 (hookName) => {
48 expect(route[hookName as keyof LazyRoute<any>]).toBeDefined()
49 },
50 )
51})