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} from '../src'
10β
11describe('createFileRoute has the same hooks as getRouteApi', () => {
12 const routeApi = getRouteApi('foo')
13 const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))
14 // @ts-expect-error
15 const route = createFileRoute('')({})
16β
17 it.each(hookNames.map((name) => [name]))(
18 'should have the "%s" hook defined',
19 (hookName) => {
20 expect(route[hookName as keyof LazyRoute<any>]).toBeDefined()
21 },
22 )
23})
24β
25describe('createLazyFileRoute has the same hooks as getRouteApi', () => {
26 const routeApi = getRouteApi('foo')
27 const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))
28 // @ts-expect-error
29 const route = createLazyFileRoute('')({})
30β
31 it.each(hookNames.map((name) => [name]))(
32 'should have the "%s" hook defined',
33 (hookName) => {
34 expect(route[hookName as keyof LazyRoute<any>]).toBeDefined()
35 },
36 )
37})
38β
39describe('createLazyRoute has the same hooks as getRouteApi', () => {
40 const routeApi = getRouteApi('foo')
41 const route = createLazyRoute({})({})
42 const hookNames = Object.keys(routeApi).filter((key) => key.startsWith('use'))
43β
44 it.each(hookNames.map((name) => [name]))(
45 'should have the "%s" hook defined',
46 (hookName) => {
47 expect(route[hookName as keyof LazyRoute<any>]).toBeDefined()
48 },
49 )
50})