From 5f372db8dd0a4e69809a979d6580f884020895cc Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Tue, 26 Dec 2023 14:05:55 -0600 Subject: [PATCH 1/8] started working on create-route-methods implementation --- src/types/routeMethods.ts | 8 +-- src/types/routes.ts | 12 ++++- src/utilities/createRouteMethods.spec.ts | 64 ++++++++++++++++++++++++ src/utilities/createRouteMethods.ts | 30 +++++++++++ src/utilities/createRouter.ts | 7 +-- src/utilities/index.ts | 5 +- 6 files changed, 111 insertions(+), 15 deletions(-) create mode 100644 src/utilities/createRouteMethods.spec.ts create mode 100644 src/utilities/createRouteMethods.ts diff --git a/src/types/routeMethods.ts b/src/types/routeMethods.ts index 1655fea0..200fe4da 100644 --- a/src/types/routeMethods.ts +++ b/src/types/routeMethods.ts @@ -1,5 +1,5 @@ import { Param, ParamGetSet, ParamGetter } from '@/types/params' -import { Route, Routes } from '@/types/routes' +import { IsPublicRoute, Route, Routes } from '@/types/routes' import { Identity, IsAny, IsEmptyObject, ReplaceAll, TupleCanBeAllUndefined, UnionToIntersection } from '@/types/utilities' import { Path } from '@/utilities/path' @@ -44,12 +44,6 @@ type RouteMethodsOrMethod< : never : never -type IsPublicRoute = 'public' extends keyof TRoute - ? TRoute extends { public: false } - ? false - : true - : true - type CreateRouteMethod< TParams extends Record, TPath extends Route['path'] diff --git a/src/types/routes.ts b/src/types/routes.ts index a38f0907..3a7f3dac 100644 --- a/src/types/routes.ts +++ b/src/types/routes.ts @@ -44,4 +44,14 @@ export function isParentRoute(value: Route): value is ParentRoute { export function isNamedRoute(value: Route): value is Route & { name: string } { return 'name' in value && !!value.name -} \ No newline at end of file +} + +export function isPublicRoute(value: Route): value is Route & { public: true } { + return value.public !== false +} + +export type IsPublicRoute = 'public' extends keyof TRoute + ? TRoute extends { public: false } + ? false + : true + : true \ No newline at end of file diff --git a/src/utilities/createRouteMethods.spec.ts b/src/utilities/createRouteMethods.spec.ts new file mode 100644 index 00000000..d71d6a8a --- /dev/null +++ b/src/utilities/createRouteMethods.spec.ts @@ -0,0 +1,64 @@ +import { describe, expect, test } from 'vitest' +import { Routes } from '@/types' +import { createRouteMethods } from '@/utilities' + +const component = { template: '
This is component
' } + +describe('createRouteMethods', () => { + test.each([ + [undefined], + [true], + ])('given route is named and is public, makes parent callable', () => { + const routes = [ + { + name: 'parent', + path: '/parent', + component, + }, + ] as const satisfies Routes + + const response = createRouteMethods(routes) + + expect(response.parent).toBeTypeOf('function') + }) + + test('given route is NOT public, returns empty object', () => { + const routes = [ + { + name: 'parent', + path: '/parent', + public: false, + component, + }, + ] as const satisfies Routes + + const response = createRouteMethods(routes) + + expect(response).toMatchObject({}) + }) + + test.each([ + [undefined], + [true], + [false], + ])('given parent route with named children, has property for child name', (isPublic) => { + const routes = [ + { + name: 'parent', + path: '/parent', + children: [ + { + name: 'child', + path: '/child', + public: isPublic, + component, + }, + ], + }, + ] as const satisfies Routes + + const response = createRouteMethods(routes) + + expect(response.child).not.toBeUndefined() + }) +}) \ No newline at end of file diff --git a/src/utilities/createRouteMethods.ts b/src/utilities/createRouteMethods.ts new file mode 100644 index 00000000..1b06815c --- /dev/null +++ b/src/utilities/createRouteMethods.ts @@ -0,0 +1,30 @@ +import { Resolved, Route, isNamedRoute, isParentRoute, isPublicRoute } from '@/types' +import { assembleUrl } from '@/utilities/urlAssembly' + +export function createRouteMethods(routes: Resolved[]): Record { + return routes.reduce>((methods, route) => { + if (isNamedRoute(route.matched)) { + methods[route.name] = {} + + if (isPublicRoute(route.matched)) { + methods[route.name] = routeMethodInstance(route) + } + } + + if (isParentRoute(route.matched)) { + Object.assign(methods, createRouteMethods(route.children)) + } + + return methods + // use assembleUrl(route, args) to generate string URL + }, {}) +} + +export type RouteMethodInstance = (values: Record) => { url: string } +function routeMethodInstance(route: Resolved): RouteMethodInstance { + return (values) => { + const url = assembleUrl(route, values) + + return { url } + } +} \ No newline at end of file diff --git a/src/utilities/createRouter.ts b/src/utilities/createRouter.ts index 992a2a18..0840a8ff 100644 --- a/src/utilities/createRouter.ts +++ b/src/utilities/createRouter.ts @@ -1,5 +1,5 @@ import { Resolved, RouteMethods, Routes } from '@/types' -import { resolveRoutes, routeParamsAreValid } from '@/utilities' +import { createRouteMethods, resolveRoutes, routeParamsAreValid } from '@/utilities' export type Router< TRoutes extends Routes @@ -13,11 +13,6 @@ export type Router< routeMatch: (path: string) => Resolved | undefined, } -function createRouteMethods(_routes: T): RouteMethods { - // use assembleUrl(route, args) to generate string URL - return {} as any -} - export function createRouter(routes: T): Router { const resolved = resolveRoutes(routes) diff --git a/src/utilities/index.ts b/src/utilities/index.ts index c8d694e1..cf5492fb 100644 --- a/src/utilities/index.ts +++ b/src/utilities/index.ts @@ -1,8 +1,11 @@ +export * from './createRouteMethods' export * from './createRouter' export * from './mergeParams' +export * from './paramValidation' export * from './params' export * from './paramsFinder' -export * from './paramValidation' export * from './path' export * from './random' export * from './routeResolver' +export * from './string' +export * from './urlAssembly' From c339a90e8c1abceda0f76b41289911446a9df49b Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Tue, 26 Dec 2023 14:46:36 -0600 Subject: [PATCH 2/8] updated contract to use resolved routes instead of T extends Routes --- src/utilities/createRouteMethods.spec.ts | 11 +++++++---- src/utilities/createRouteMethods.ts | 20 ++++++++------------ src/utilities/createRouter.ts | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/utilities/createRouteMethods.spec.ts b/src/utilities/createRouteMethods.spec.ts index d71d6a8a..cfec4aea 100644 --- a/src/utilities/createRouteMethods.spec.ts +++ b/src/utilities/createRouteMethods.spec.ts @@ -1,6 +1,6 @@ import { describe, expect, test } from 'vitest' import { Routes } from '@/types' -import { createRouteMethods } from '@/utilities' +import { createRouteMethods, resolveRoutes } from '@/utilities' const component = { template: '
This is component
' } @@ -16,8 +16,9 @@ describe('createRouteMethods', () => { component, }, ] as const satisfies Routes + const resolved = resolveRoutes(routes) - const response = createRouteMethods(routes) + const response = createRouteMethods(resolved) expect(response.parent).toBeTypeOf('function') }) @@ -31,8 +32,9 @@ describe('createRouteMethods', () => { component, }, ] as const satisfies Routes + const resolved = resolveRoutes(routes) - const response = createRouteMethods(routes) + const response = createRouteMethods(resolved) expect(response).toMatchObject({}) }) @@ -56,8 +58,9 @@ describe('createRouteMethods', () => { ], }, ] as const satisfies Routes + const resolved = resolveRoutes(routes) - const response = createRouteMethods(routes) + const response = createRouteMethods(resolved) expect(response.child).not.toBeUndefined() }) diff --git a/src/utilities/createRouteMethods.ts b/src/utilities/createRouteMethods.ts index 1b06815c..debe822e 100644 --- a/src/utilities/createRouteMethods.ts +++ b/src/utilities/createRouteMethods.ts @@ -1,25 +1,21 @@ -import { Resolved, Route, isNamedRoute, isParentRoute, isPublicRoute } from '@/types' +import { Resolved, Route, isPublicRoute } from '@/types' import { assembleUrl } from '@/utilities/urlAssembly' export function createRouteMethods(routes: Resolved[]): Record { return routes.reduce>((methods, route) => { - if (isNamedRoute(route.matched)) { - methods[route.name] = {} - - if (isPublicRoute(route.matched)) { - methods[route.name] = routeMethodInstance(route) - } - } - - if (isParentRoute(route.matched)) { - Object.assign(methods, createRouteMethods(route.children)) - } + Object.assign(methods, assembleRouteParentContext(route)) return methods // use assembleUrl(route, args) to generate string URL }, {}) } +export function assembleRouteParentContext(route: Resolved): Record { + return { + [route.name]: isPublicRoute(route.matched) ? routeMethodInstance(route) : {}, + } +} + export type RouteMethodInstance = (values: Record) => { url: string } function routeMethodInstance(route: Resolved): RouteMethodInstance { return (values) => { diff --git a/src/utilities/createRouter.ts b/src/utilities/createRouter.ts index 0840a8ff..acf9e7f9 100644 --- a/src/utilities/createRouter.ts +++ b/src/utilities/createRouter.ts @@ -41,7 +41,7 @@ export function createRouter(routes: T): Router { } const router = { - routes: createRouteMethods(routes), + routes: createRouteMethods(resolved), push, replace, forward, From cbbf8637bf98efc321d33cc96d460851983511ba Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Tue, 26 Dec 2023 16:57:04 -0600 Subject: [PATCH 3/8] first attempt at combining route methods --- src/types/resolved.ts | 2 +- src/utilities/createRouteMethods.spec.ts | 27 ++++++++++++++++++++++++ src/utilities/createRouteMethods.ts | 19 +++++++++++------ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/src/types/resolved.ts b/src/types/resolved.ts index 827cf65a..bf61e9ac 100644 --- a/src/types/resolved.ts +++ b/src/types/resolved.ts @@ -6,6 +6,6 @@ export type Resolved = { name: string, path: string, regex: RegExp, - parentNames: T['name'][], + parentNames: string[], params: Record, } \ No newline at end of file diff --git a/src/utilities/createRouteMethods.spec.ts b/src/utilities/createRouteMethods.spec.ts index cfec4aea..ab3109f3 100644 --- a/src/utilities/createRouteMethods.spec.ts +++ b/src/utilities/createRouteMethods.spec.ts @@ -64,4 +64,31 @@ describe('createRouteMethods', () => { expect(response.child).not.toBeUndefined() }) + + test.only('given parent route with named children and grandchildren, has path to grandchild', () => { + const routes = [ + { + name: 'parent', + path: '/parent', + children: [ + { + name: 'child', + path: '/child', + children: [ + { + name: 'grandchild', + path: '/grandchild', + component, + }, + ], + }, + ], + }, + ] as const satisfies Routes + const resolved = resolveRoutes(routes) + + const response = createRouteMethods(resolved) + + expect(response.child.grandchild).not.toBeUndefined() + }) }) \ No newline at end of file diff --git a/src/utilities/createRouteMethods.ts b/src/utilities/createRouteMethods.ts index debe822e..6bbe154e 100644 --- a/src/utilities/createRouteMethods.ts +++ b/src/utilities/createRouteMethods.ts @@ -1,18 +1,25 @@ import { Resolved, Route, isPublicRoute } from '@/types' import { assembleUrl } from '@/utilities/urlAssembly' -export function createRouteMethods(routes: Resolved[]): Record { - return routes.reduce>((methods, route) => { - Object.assign(methods, assembleRouteParentContext(route)) +export function createRouteMethods(routes: Resolved[]): Record { + return routes.reduce>((methods, route) => { + const thing = assembleRouteParentContext(route, [...route.parentNames]) + + console.log(JSON.stringify(thing)) return methods - // use assembleUrl(route, args) to generate string URL }, {}) } -export function assembleRouteParentContext(route: Resolved): Record { +export function assembleRouteParentContext(route: Resolved, parentNames: string[]): Record { + const nextLevel = parentNames.shift() + + if (!nextLevel) { + return isPublicRoute(route.matched) ? routeMethodInstance(route) : {} + } + return { - [route.name]: isPublicRoute(route.matched) ? routeMethodInstance(route) : {}, + [nextLevel]: assembleRouteParentContext(route, parentNames), } } From 486982131eed431e37aae31790d228026edadac9 Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Wed, 27 Dec 2023 14:19:31 -0600 Subject: [PATCH 4/8] improved implementation of createRouteMethods --- src/utilities/createRouteMethods.spec.ts | 12 +++-- src/utilities/createRouteMethods.ts | 62 ++++++++++++++++-------- 2 files changed, 51 insertions(+), 23 deletions(-) diff --git a/src/utilities/createRouteMethods.spec.ts b/src/utilities/createRouteMethods.spec.ts index ab3109f3..d46ac30f 100644 --- a/src/utilities/createRouteMethods.spec.ts +++ b/src/utilities/createRouteMethods.spec.ts @@ -62,10 +62,14 @@ describe('createRouteMethods', () => { const response = createRouteMethods(resolved) - expect(response.child).not.toBeUndefined() + expect(response.parent.child).not.toBeUndefined() + + if (isPublic !== false) { + expect(response.parent.child).toBeTypeOf('function') + } }) - test.only('given parent route with named children and grandchildren, has path to grandchild', () => { + test('given parent route with named children and grandchildren, has path to grandchild all callable', () => { const routes = [ { name: 'parent', @@ -89,6 +93,8 @@ describe('createRouteMethods', () => { const response = createRouteMethods(resolved) - expect(response.child.grandchild).not.toBeUndefined() + expect(response.parent).toBeTypeOf('function') + expect(response.parent.child).toBeTypeOf('function') + expect(response.parent.child.grandchild).toBeTypeOf('function') }) }) \ No newline at end of file diff --git a/src/utilities/createRouteMethods.ts b/src/utilities/createRouteMethods.ts index 6bbe154e..ebf32932 100644 --- a/src/utilities/createRouteMethods.ts +++ b/src/utilities/createRouteMethods.ts @@ -1,33 +1,55 @@ -import { Resolved, Route, isPublicRoute } from '@/types' +import { Resolved, Route, RouteMethodRoute, isPublicRoute } from '@/types' import { assembleUrl } from '@/utilities/urlAssembly' -export function createRouteMethods(routes: Resolved[]): Record { - return routes.reduce>((methods, route) => { - const thing = assembleRouteParentContext(route, [...route.parentNames]) +type NonCallableNode = Record +type CallableNode = NonCallableNode & { + (values: Record): RouteMethodRoute, +} +type Node = CallableNode | NonCallableNode + +export function createRouteMethods(routes: Resolved[]): Record { + const methods: Record = {} + + routes.forEach(route => { + const currentLevel = traverseParents(route, methods) + const routeNode = createNodeForRoute(route) - console.log(JSON.stringify(thing)) + Object.assign(routeNode, currentLevel[route.name]) - return methods - }, {}) + currentLevel[route.name] = routeNode + }) + + return methods } -export function assembleRouteParentContext(route: Resolved, parentNames: string[]): Record { - const nextLevel = parentNames.shift() +function traverseParents(route: Resolved, currentLevel: Record): Record { + route.parentNames.forEach(parentName => { + if (!currentLevel[parentName]) { + currentLevel[parentName] = {} + } - if (!nextLevel) { - return isPublicRoute(route.matched) ? routeMethodInstance(route) : {} - } + currentLevel = currentLevel[parentName] + }) - return { - [nextLevel]: assembleRouteParentContext(route, parentNames), - } + return currentLevel } -export type RouteMethodInstance = (values: Record) => { url: string } -function routeMethodInstance(route: Resolved): RouteMethodInstance { - return (values) => { - const url = assembleUrl(route, values) +function createNodeForRoute(route: Resolved): Node { + if (isPublicRoute(route.matched)) { + return createCallableNode(route) + } - return { url } + return {} +} + +function createCallableNode(route: Resolved): CallableNode { + const node: CallableNode = (values) => { + return { + push: () => null, + replace: () => null, + url: assembleUrl(route, values), + } } + + return node } \ No newline at end of file From 5abf5c6f9b0606035d9b4213d5659eacf2e15934 Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Thu, 28 Dec 2023 09:19:23 -0600 Subject: [PATCH 5/8] updated types for public route --- src/types/routeMethods.ts | 6 +++--- src/types/routes.ts | 12 ++++-------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/src/types/routeMethods.ts b/src/types/routeMethods.ts index 200fe4da..ac388b8d 100644 --- a/src/types/routeMethods.ts +++ b/src/types/routeMethods.ts @@ -1,5 +1,5 @@ import { Param, ParamGetSet, ParamGetter } from '@/types/params' -import { IsPublicRoute, Route, Routes } from '@/types/routes' +import { Public, Route, Routes } from '@/types/routes' import { Identity, IsAny, IsEmptyObject, ReplaceAll, TupleCanBeAllUndefined, UnionToIntersection } from '@/types/utilities' import { Path } from '@/utilities/path' @@ -34,12 +34,12 @@ type RouteMethodsOrMethod< TParams extends Record > = TRoute extends { path: infer Path, children: infer Children } ? Children extends Routes - ? IsPublicRoute extends true + ? TRoute extends Public ? RouteMethods>> & CreateRouteMethod : RouteMethods>> : never : TRoute extends { path: infer Path } - ? IsPublicRoute extends true + ? TRoute extends Public ? CreateRouteMethod : never : never diff --git a/src/types/routes.ts b/src/types/routes.ts index 3a7f3dac..904b2726 100644 --- a/src/types/routes.ts +++ b/src/types/routes.ts @@ -46,12 +46,8 @@ export function isNamedRoute(value: Route): value is Route & { name: string } { return 'name' in value && !!value.name } -export function isPublicRoute(value: Route): value is Route & { public: true } { - return value.public !== false -} +export type Public = T & { public?: true | undefined } -export type IsPublicRoute = 'public' extends keyof TRoute - ? TRoute extends { public: false } - ? false - : true - : true \ No newline at end of file +export function isPublicRoute(value: Route): value is Public { + return value.public !== false +} \ No newline at end of file From 6458a53bd33bdd5c5f798e7feb9fa404619b7f7a Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Thu, 28 Dec 2023 09:20:20 -0600 Subject: [PATCH 6/8] using param on test.each --- src/utilities/createRouteMethods.spec.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/utilities/createRouteMethods.spec.ts b/src/utilities/createRouteMethods.spec.ts index d46ac30f..e9f165c1 100644 --- a/src/utilities/createRouteMethods.spec.ts +++ b/src/utilities/createRouteMethods.spec.ts @@ -8,11 +8,12 @@ describe('createRouteMethods', () => { test.each([ [undefined], [true], - ])('given route is named and is public, makes parent callable', () => { + ])('given route is named and is public, makes parent callable', (isPublic) => { const routes = [ { name: 'parent', path: '/parent', + public: isPublic, component, }, ] as const satisfies Routes From c409c705644bd1d3f1cd868218c9f07215c4497e Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Thu, 28 Dec 2023 09:21:28 -0600 Subject: [PATCH 7/8] renamed random to testHelpers, moved component const in --- src/types/routeMethods.test-d.ts | 3 +-- src/utilities/createRouteMethods.spec.ts | 3 +-- src/utilities/createRouter.spec.ts | 3 +-- src/utilities/index.ts | 1 - src/utilities/paramValidation.spec.ts | 3 +-- src/utilities/routeResolver.spec.ts | 3 +-- src/utilities/{random.ts => testHelpers.ts} | 4 +++- src/utilities/urlAssembly.spec.ts | 3 +-- 8 files changed, 9 insertions(+), 14 deletions(-) rename src/utilities/{random.ts => testHelpers.ts} (77%) diff --git a/src/types/routeMethods.test-d.ts b/src/types/routeMethods.test-d.ts index 5c83829c..12bcea50 100644 --- a/src/types/routeMethods.test-d.ts +++ b/src/types/routeMethods.test-d.ts @@ -2,8 +2,7 @@ import { test, expectTypeOf } from 'vitest' import { ParamGetSet } from '@/types/params' import { Routes } from '@/types/routes' import { createRouter, path } from '@/utilities' - -const component = { template: '
This is component
' } +import { component } from '@/utilities/testHelpers' const boolean: ParamGetSet = { get: value => Boolean(value), diff --git a/src/utilities/createRouteMethods.spec.ts b/src/utilities/createRouteMethods.spec.ts index e9f165c1..778a0fa1 100644 --- a/src/utilities/createRouteMethods.spec.ts +++ b/src/utilities/createRouteMethods.spec.ts @@ -1,8 +1,7 @@ import { describe, expect, test } from 'vitest' import { Routes } from '@/types' import { createRouteMethods, resolveRoutes } from '@/utilities' - -const component = { template: '
This is component
' } +import { component } from '@/utilities/testHelpers' describe('createRouteMethods', () => { test.each([ diff --git a/src/utilities/createRouter.spec.ts b/src/utilities/createRouter.spec.ts index 2c2dd2e0..ca52c999 100644 --- a/src/utilities/createRouter.spec.ts +++ b/src/utilities/createRouter.spec.ts @@ -1,8 +1,7 @@ import { describe, expect, test } from 'vitest' import { Routes } from '@/types' import { createRouter } from '@/utilities' - -const component = { template: '
This is component
' } +import { component } from '@/utilities/testHelpers' describe('router.routeMatch', () => { test('given path WITHOUT params, returns match', () => { diff --git a/src/utilities/index.ts b/src/utilities/index.ts index cf5492fb..72848089 100644 --- a/src/utilities/index.ts +++ b/src/utilities/index.ts @@ -5,7 +5,6 @@ export * from './paramValidation' export * from './params' export * from './paramsFinder' export * from './path' -export * from './random' export * from './routeResolver' export * from './string' export * from './urlAssembly' diff --git a/src/utilities/paramValidation.spec.ts b/src/utilities/paramValidation.spec.ts index 921887b2..02b2ea11 100644 --- a/src/utilities/paramValidation.spec.ts +++ b/src/utilities/paramValidation.spec.ts @@ -1,8 +1,7 @@ import { describe, expect, test } from 'vitest' import { Route } from '@/types' import { resolveRoutes, routeParamsAreValid, path } from '@/utilities' - -const component = { template: '
This is component
' } +import { component } from '@/utilities/testHelpers' describe('routeParamsAreValid', () => { test('given route WITHOUT params, always return true', () => { diff --git a/src/utilities/routeResolver.spec.ts b/src/utilities/routeResolver.spec.ts index 14f12d44..4c6ca83f 100644 --- a/src/utilities/routeResolver.spec.ts +++ b/src/utilities/routeResolver.spec.ts @@ -1,8 +1,7 @@ import { describe, expect, test } from 'vitest' import { Route, Routes } from '@/types' import { resolveRoutes, generateRouteRegexPattern, path } from '@/utilities' - -const component = { template: '
This is component
' } +import { component } from '@/utilities/testHelpers' describe('resolveRoutes', () => { test('always returns 1 record per named route', () => { diff --git a/src/utilities/random.ts b/src/utilities/testHelpers.ts similarity index 77% rename from src/utilities/random.ts rename to src/utilities/testHelpers.ts index 22d5fcf6..561535ff 100644 --- a/src/utilities/random.ts +++ b/src/utilities/testHelpers.ts @@ -5,4 +5,6 @@ export const random = { return randomNumber }, -} \ No newline at end of file +} + +export const component = { template: '
This is component
' } \ No newline at end of file diff --git a/src/utilities/urlAssembly.spec.ts b/src/utilities/urlAssembly.spec.ts index 08d819c0..4b47e4a1 100644 --- a/src/utilities/urlAssembly.spec.ts +++ b/src/utilities/urlAssembly.spec.ts @@ -1,10 +1,9 @@ import { describe, expect, test } from 'vitest' import { InvalidRouteParamValueError, Route } from '@/types' import { path, resolveRoutes } from '@/utilities' +import { component } from '@/utilities/testHelpers' import { assembleUrl } from '@/utilities/urlAssembly' -const component = { template: '
This is component
' } - describe('assembleUrl', () => { test.each([ ['/simple'], From cf7a457e7bb13992ade3b45d0ad9f07beb899b14 Mon Sep 17 00:00:00 2001 From: Evan Sutherland Date: Thu, 28 Dec 2023 09:22:05 -0600 Subject: [PATCH 8/8] prefer toBeDefined over not.toBeUndefined --- src/utilities/createRouteMethods.spec.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utilities/createRouteMethods.spec.ts b/src/utilities/createRouteMethods.spec.ts index 778a0fa1..490bf706 100644 --- a/src/utilities/createRouteMethods.spec.ts +++ b/src/utilities/createRouteMethods.spec.ts @@ -62,7 +62,7 @@ describe('createRouteMethods', () => { const response = createRouteMethods(resolved) - expect(response.parent.child).not.toBeUndefined() + expect(response.parent.child).toBeDefined() if (isPublic !== false) { expect(response.parent.child).toBeTypeOf('function')