Skip to content

📝 Test Cases

Complete list of all test cases across 9 test files (140 tests).

For testing setup, helpers, and how to write new tests, see the Testing Guide.


Registry management functions.

createRegistry

TestDescription
returns empty registry structureCreates Maps and sorted arrays

register

TestDescription
adds outpost to global registryRegisters global scope outpost
adds outpost to route registryRegisters route scope outpost
warns on duplicate and replaces existingLogs warning, overwrites
updates sorted array by priorityMaintains priority order
uses defaultPriority for outposts without priorityFalls back to default

unregister

TestDescription
removes outpost and returns trueSuccessful removal
returns false if outpost not foundNon-existent outpost
updates sorted array after removalRe-sorts after delete

getRegisteredNames

TestDescription
returns global outpost namesLists global names
returns route outpost namesLists route names
returns empty array when no outpostsEmpty registry case

Outcome normalization and patrol logic.

normalizeOutcome

TestDescription
returns ALLOW as-isValid verdict passthrough
returns BLOCK as-isValid verdict passthrough
validates RouteLocationRaw string path/login format
validates RouteLocationRaw object with name{ name: 'login' } format
validates RouteLocationRaw object with path{ path: '/login' } format
throws on invalid routeRoute not found in router
throws Error outcomeRe-throws Error instances
throws on invalid outcome typeRejects invalid types

toNavigationGuardReturn

TestDescription
converts ALLOW to trueVue Router format
converts BLOCK to falseVue Router format
returns RouteLocationRaw as-isRedirect passthrough

patrol

TestDescription
returns ALLOW when no outpostsEmpty registry case
processes global outposts in priority orderLower priority first
stops on BLOCKShort-circuit on block
stops on redirectShort-circuit on redirect
filters outposts by hookbeforeEach vs beforeResolve
processes route outposts after globalExecution order
warns on duplicate route outpostsNested route deduplication
silently skips route outposts not found in registryMissing outpost handling

Public API testing.

createNavigationCitadel

TestDescription
returns API object with all methodsAPI shape validation
registers router hooksbeforeEach, beforeResolve, afterEach
deploys initial outposts from optionsConstructor outposts
uses custom loggerLogger injection

deployOutpost

TestDescription
deploys single outpostSingle object
deploys outpost with default scope (global)Scope defaults to global
deploys multiple outposts (array)Array of outposts

abandonOutpost

TestDescription
removes single outpost and returns trueSuccessful removal
returns false if outpost not foundNon-existent outpost
removes multiple outposts and returns true if all deletedArray removal
returns false if any outpost not foundPartial failure

getOutpostNames

TestDescription
returns global outpost namesGlobal scope
returns route outpost namesRoute scope
returns empty array when no outpostsEmpty case

assignOutpostToRoute

TestDescription
assigns outpost to existing routeModifies route meta
assigns multiple outposts to routeArray assignment
does not duplicate outpostsIdempotent
returns false if route not foundNon-existent route

revokeOutpostFromRoute

TestDescription
removes single outpost from routeSingle outpost removal
removes multiple outposts from routeArray removal
returns false if route not foundNon-existent route
warns if outpost not in route outpostsMissing outpost warning
handles missing meta.outposts gracefullyNo meta.outposts edge case

destroy

TestDescription
removes hooks and clears registryCleanup

install

TestDescription
is callable as Vue pluginPlugin API compatibility
does nothing when devtools disabledNo-op when disabled

logging

TestDescription
logs assignOutpostToRoute when log enabledAssignment logging
logs revokeOutpostFromRoute when log enabledRevocation logging
logs destroy when log enabledDestruction logging

timeout.test.ts (5 tests)

Timeout functionality.

TestDescription
outpost times out and returns BLOCK by defaultDefault timeout behavior
onTimeout handler is called on timeoutCustom handler invocation
per-outpost timeout overrides defaultTimeoutPriority of timeouts
no timeout if not configuredDisabled timeout
fast outpost completes before timeoutNo false positives

lazy.test.ts (12 tests)

Lazy outpost loading functionality.

loading behavior

TestDescription
should load lazy outpost on first navigationModule loaded on demand
should cache handler after first loadSubsequent calls use cache
should not load eager outpost lazilyEager handlers work as before

error handling

TestDescription
should handle module load erroronError called on load fail
should throw error if module has no default exportInvalid module format
should allow retry after load errorRetry on next navigation

timeout behavior

TestDescription
should apply timeout only to handler execution, not loadingLoading time not counted
should timeout if handler execution exceeds timeoutExecution timeout works

logging

TestDescription
should log lazy flag when deploying"(lazy)" in log message
should not log lazy flag for eager outpostsNo "(lazy)" for eager

mixed eager and lazy outposts

TestDescription
should process eager and lazy outposts in priority orderPriority ordering works

getOutpostNames

TestDescription
should return names of both eager and lazy outpostsBoth types listed

integration.test.ts (13 tests)

Full navigation flows with real router.

TestDescription
allows navigation when all outposts return ALLOWHappy path
blocks navigation when outpost returns BLOCKBlock scenario
redirects when outpost returns RouteLocationRawRedirect scenario
processes outposts in priority orderEnd-to-end priority

error handling

TestDescription
calls onError handler on errorCustom error handler
blocks navigation by default on errorDefault error behavior
onError can redirect on errorError -> redirect

hooks

TestDescription
runs outpost on specified hooks onlyHook filtering
runs outpost on multiple hooksMulti-hook outpost
afterEach runs for side effects onlyPost-navigation

route outposts

TestDescription
processes route outposts from metaRoute meta integration
skips route outposts for routes without metaNo meta case

context

TestDescription
provides correct context to handlerContext shape

devtools-settings.test.ts (19 tests)

DevTools settings and localStorage persistence.

logLevelToState

TestDescription
should convert OFF to log:false, debug:falseState mapping
should convert LOG to log:true, debug:falseState mapping
should convert DEBUG to log:true, debug:trueState mapping

stateToLogLevel

TestDescription
should convert log:false, debug:false to OFFReverse mapping
should convert log:true, debug:false to LOGReverse mapping
should convert log:true, debug:true to DEBUGReverse mapping
should convert log:false, debug:true to DEBUG (precedence)Edge case, debug wins

initializeRuntimeState

TestDescription
should use localStorage value when availablelocalStorage priority
should use citadel options when localStorage emptyOptions priority
should use defaults when no localStorage/optionsDefault priority
should prioritize debug option over log optiondebug forces log
should respect log=false when debug=falseExplicit off
should ignore invalid localStorage valueInvalid values ignored

updateRuntimeState

TestDescription
should update state to OFFState mutation + persist
should update state to LOGState mutation + persist
should update state to DEBUGState mutation + persist

createSettingsDefinition

TestDescription
should create settings with current state as defaultDevTools settings shape
should set default to OFF when log and debug are falseOFF state mapping
should set default to DEBUG when debug is trueDEBUG state mapping

devtools-inspector.test.ts (19 tests)

DevTools custom inspector functionality.

createInspectorTree

TestDescription
should create empty tree when no outpostsEmpty registry case
should include global outposts in treeGlobal scope in tree
should include route outposts in treeRoute scope in tree
should add priority tag to outpost nodesPriority display
should add hooks tag to outpost nodesHooks count display
should add lazy tag for lazy outpostsLazy indicator

getNodeState

TestDescription
should return null for non-outpost nodesRoot node handling
should return null for invalid node idInvalid ID handling
should return state for global outpost nodeGlobal outpost state
should return state for route outpost nodeRoute outpost state
should return null for non-existent outpostMissing outpost
should show "none (uses default)" for undefined timeoutTimeout display

setupInspector

TestDescription
should add inspector to DevTools APIInspector registration
should register getInspectorTree callbackTree callback
should register getInspectorState callbackState callback
should populate rootNodes on getInspectorTree callbackTree population
should ignore getInspectorTree for other inspectorsInspector ID check
should populate state on getInspectorState callbackState population

refreshInspector

TestDescription
should call sendInspectorTree and sendInspectorStateRefresh calls

debugHandler.test.ts (12 tests)

Debug handler invocation, custom handlers, and default logger.

debugPoint function

TestDescription
calls logger.debug when debug is trueDebug logging
calls debugHandler when debug is trueHandler invocation
does not call logger.debug when debug falseNo logging when disabled
does not call debugHandler when debug falseNo handler when disabled
works without debugHandler (optional)Optional handler
passes debug point name to handlerCorrect name passed

createDefaultDebugHandler

TestDescription
returns a functionFactory returns handler
handler can be called without errorHandler is callable

custom debugHandler integration

TestDescription
should use custom debugHandlerCustom handler used
should allow debugHandler custom actionsCustom tracing

createDefaultLogger

TestDescription
should return logger with all methodsLogger shape
should call console methods with prefixPrefix verification

Released under the MIT License.