diff --git a/src/app/app.routes.ts b/src/app/app.routes.ts index 71bcc95..a9e300b 100644 --- a/src/app/app.routes.ts +++ b/src/app/app.routes.ts @@ -16,6 +16,10 @@ export const routes: Routes = [ loadComponent: () => import('./pages/editor/editor-page').then((m) => m.EditorPageComponent), }, + { + path: '**', + redirectTo: '', + }, ], }, ]; diff --git a/src/app/app.spec.ts b/src/app/app.spec.ts index 784fb3f..6ada662 100644 --- a/src/app/app.spec.ts +++ b/src/app/app.spec.ts @@ -1,6 +1,7 @@ import { TestBed } from '@angular/core/testing'; import { provideRouter } from '@angular/router'; import { App } from './app'; +import { routes } from './app.routes'; describe('App', () => { beforeEach(async () => { @@ -16,3 +17,19 @@ describe('App', () => { expect(app).toBeTruthy(); }); }); + +describe('Routes', () => { + const shellRoute = routes[0]; + const childRoutes = shellRoute.children!; + + it('should have a wildcard route that redirects to root', () => { + const wildcard = childRoutes.find((r) => r.path === '**'); + expect(wildcard).toBeDefined(); + expect(wildcard!.redirectTo).toBe(''); + }); + + it('should place the wildcard route last', () => { + const last = childRoutes[childRoutes.length - 1]; + expect(last.path).toBe('**'); + }); +});