diff --git a/src/types/routeMethods.test-d.ts b/src/types/routeMethods.test-d.ts index f38b5afc..9a13d282 100644 --- a/src/types/routeMethods.test-d.ts +++ b/src/types/routeMethods.test-d.ts @@ -3,8 +3,7 @@ import { ParamGetSet } from '@/types/params' import { RouteMethodOptions } from '@/types/routeMethods' 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/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 88171036..89b6a9b4 100644 --- a/src/utilities/index.ts +++ b/src/utilities/index.ts @@ -4,8 +4,8 @@ export * from './paramValidation' export * from './params' export * from './paramsFinder' export * from './path' -export * from './random' export * from './routeRegex' export * from './routeResolver' export * from './string' +export * from './testHelpers' 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 d5c4c3a7..0eaf2713 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, 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'],