feat: implement store layout and home page components with routing
This commit is contained in:
44
src/app/app.routes.spec.ts
Normal file
44
src/app/app.routes.spec.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideRouter, Router } from '@angular/router';
|
||||
|
||||
import { App } from './app';
|
||||
import { routes } from './app.routes';
|
||||
|
||||
async function renderAppAt(url: string) {
|
||||
TestBed.resetTestingModule();
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [App],
|
||||
providers: [provideRouter(routes)]
|
||||
}).compileComponents();
|
||||
|
||||
const router = TestBed.inject(Router);
|
||||
const fixture = TestBed.createComponent(App);
|
||||
|
||||
fixture.detectChanges();
|
||||
await router.navigateByUrl(url);
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
|
||||
return { fixture, router };
|
||||
}
|
||||
|
||||
describe('app routes', () => {
|
||||
it('loads the store layout at /store', async () => {
|
||||
const { fixture, router } = await renderAppAt('/store');
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
|
||||
expect(router.url).toBe('/store');
|
||||
expect(compiled.querySelector('.store-layout')).not.toBeNull();
|
||||
expect(compiled.querySelector('.store-home')).not.toBeNull();
|
||||
expect(compiled.textContent).toContain('Tienda en construccion');
|
||||
});
|
||||
|
||||
it('keeps the root redirect under componentes-test', async () => {
|
||||
const { fixture, router } = await renderAppAt('/');
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
|
||||
expect(router.url).toBe('/componentes-test/reutilizables');
|
||||
expect(compiled.textContent).toContain('Componentes reutilizables');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user