|
7 | 7 | */ |
8 | 8 |
|
9 | 9 | import {NgModuleRef} from '@angular/core'; |
10 | | -import {fakeAsync, TestBed, tick} from '@angular/core/testing'; |
| 10 | +import {TestBed} from '@angular/core/testing'; |
11 | 11 | import {Observable, of} from 'rxjs'; |
12 | | -import {delay, tap} from 'rxjs/operators'; |
| 12 | +import {delay} from 'rxjs/operators'; |
13 | 13 |
|
14 | 14 | import {applyRedirects} from '../src/apply_redirects'; |
15 | 15 | import {LoadedRouterConfig, Route, Routes} from '../src/config'; |
@@ -482,89 +482,6 @@ describe('applyRedirects', () => { |
482 | 482 | expect((config[0] as any)._loadedConfig).toBe(loadedConfig); |
483 | 483 | }); |
484 | 484 | }); |
485 | | - |
486 | | - it('should load all matching configurations of empty path, including an auxiliary outlets', |
487 | | - fakeAsync(() => { |
488 | | - const loadedConfig = |
489 | | - new LoadedRouterConfig([{path: '', component: ComponentA}], testModule); |
490 | | - let loadCalls = 0; |
491 | | - let loaded: string[] = []; |
492 | | - const loader = { |
493 | | - load: (injector: any, p: Route) => { |
494 | | - loadCalls++; |
495 | | - return of(loadedConfig) |
496 | | - .pipe( |
497 | | - delay(100 * loadCalls), |
498 | | - tap(() => loaded.push(p.loadChildren! as string)), |
499 | | - ); |
500 | | - } |
501 | | - }; |
502 | | - |
503 | | - const config: Routes = |
504 | | - [{path: '', loadChildren: 'root'}, {path: '', loadChildren: 'aux', outlet: 'popup'}]; |
505 | | - |
506 | | - applyRedirects(testModule.injector, <any>loader, serializer, tree(''), config).subscribe(); |
507 | | - expect(loadCalls).toBe(1); |
508 | | - tick(100); |
509 | | - expect(loaded).toEqual(['root']); |
510 | | - tick(200); |
511 | | - expect(loadCalls).toBe(2); |
512 | | - expect(loaded).toEqual(['root', 'aux']); |
513 | | - })); |
514 | | - |
515 | | - it('loads only the first match when two Routes with the same outlet have the same path', () => { |
516 | | - const loadedConfig = new LoadedRouterConfig([{path: '', component: ComponentA}], testModule); |
517 | | - let loadCalls = 0; |
518 | | - let loaded: string[] = []; |
519 | | - const loader = { |
520 | | - load: (injector: any, p: Route) => { |
521 | | - loadCalls++; |
522 | | - return of(loadedConfig) |
523 | | - .pipe( |
524 | | - tap(() => loaded.push(p.loadChildren! as string)), |
525 | | - ); |
526 | | - } |
527 | | - }; |
528 | | - |
529 | | - const config: Routes = |
530 | | - [{path: 'a', loadChildren: 'first'}, {path: 'a', loadChildren: 'second'}]; |
531 | | - |
532 | | - applyRedirects(testModule.injector, <any>loader, serializer, tree('a'), config).subscribe(); |
533 | | - expect(loadCalls).toBe(1); |
534 | | - expect(loaded).toEqual(['first']); |
535 | | - }); |
536 | | - |
537 | | - it('should load the configuration of empty root path if the entry is an aux outlet', |
538 | | - fakeAsync(() => { |
539 | | - const loadedConfig = |
540 | | - new LoadedRouterConfig([{path: '', component: ComponentA}], testModule); |
541 | | - let loaded: string[] = []; |
542 | | - const rootDelay = 100; |
543 | | - const auxDelay = 1; |
544 | | - const loader = { |
545 | | - load: (injector: any, p: Route) => { |
546 | | - const delayMs = p.loadChildren! as string === 'aux' ? auxDelay : rootDelay; |
547 | | - return of(loadedConfig) |
548 | | - .pipe( |
549 | | - delay(delayMs), |
550 | | - tap(() => loaded.push(p.loadChildren! as string)), |
551 | | - ); |
552 | | - } |
553 | | - }; |
554 | | - |
555 | | - const config: Routes = [ |
556 | | - // Define aux route first so it matches before the primary outlet |
557 | | - {path: 'modal', loadChildren: 'aux', outlet: 'popup'}, |
558 | | - {path: '', loadChildren: 'root'}, |
559 | | - ]; |
560 | | - |
561 | | - applyRedirects(testModule.injector, <any>loader, serializer, tree('(popup:modal)'), config) |
562 | | - .subscribe(); |
563 | | - tick(auxDelay); |
564 | | - expect(loaded).toEqual(['aux']); |
565 | | - tick(rootDelay); |
566 | | - expect(loaded).toEqual(['aux', 'root']); |
567 | | - })); |
568 | 485 | }); |
569 | 486 |
|
570 | 487 | describe('empty paths', () => { |
@@ -837,46 +754,6 @@ describe('applyRedirects', () => { |
837 | 754 | }); |
838 | 755 | }); |
839 | 756 |
|
840 | | - describe('multiple matches with empty path named outlets', () => { |
841 | | - it('should work with redirects when other outlet comes before the one being activated', () => { |
842 | | - applyRedirects( |
843 | | - testModule.injector, null!, serializer, tree(''), |
844 | | - [ |
845 | | - { |
846 | | - path: '', |
847 | | - children: [ |
848 | | - {path: '', component: ComponentA, outlet: 'aux'}, |
849 | | - {path: '', redirectTo: 'b', pathMatch: 'full'}, |
850 | | - {path: 'b', component: ComponentB}, |
851 | | - ], |
852 | | - }, |
853 | | - ]) |
854 | | - .subscribe( |
855 | | - (tree: UrlTree) => { |
856 | | - expect(tree.toString()).toEqual('/b'); |
857 | | - }, |
858 | | - () => { |
859 | | - fail('should not be reached'); |
860 | | - }); |
861 | | - }); |
862 | | - |
863 | | - it('should work when entry point is named outlet', () => { |
864 | | - applyRedirects( |
865 | | - testModule.injector, null!, serializer, tree('(popup:modal)'), |
866 | | - [ |
867 | | - {path: '', component: ComponentA}, |
868 | | - {path: 'modal', component: ComponentB, outlet: 'popup'}, |
869 | | - ]) |
870 | | - .subscribe( |
871 | | - (tree: UrlTree) => { |
872 | | - expect(tree.toString()).toEqual('/(popup:modal)'); |
873 | | - }, |
874 | | - (e) => { |
875 | | - fail('should not be reached' + e.message); |
876 | | - }); |
877 | | - }); |
878 | | - }); |
879 | | - |
880 | 757 | describe('redirecting to named outlets', () => { |
881 | 758 | it('should work when using absolute redirects', () => { |
882 | 759 | checkRedirect( |
|
0 commit comments