@@ -13,6 +13,8 @@ import {By} from '@angular/platform-browser/src/dom/debug/by';
13
13
import { expect } from '@angular/platform-browser/testing/src/matchers' ;
14
14
import { ActivatedRoute , ActivatedRouteSnapshot , CanActivate , CanDeactivate , DetachedRouteHandle , Event , GuardsCheckEnd , GuardsCheckStart , NavigationCancel , NavigationEnd , NavigationError , NavigationStart , PRIMARY_OUTLET , ParamMap , Params , PreloadAllModules , PreloadingStrategy , Resolve , ResolveEnd , ResolveStart , RouteConfigLoadEnd , RouteConfigLoadStart , RouteReuseStrategy , Router , RouterModule , RouterPreloader , RouterStateSnapshot , RoutesRecognized , RunGuardsAndResolvers , UrlHandlingStrategy , UrlSegmentGroup , UrlTree } from '@angular/router' ;
15
15
import { Observable } from 'rxjs/Observable' ;
16
+ import { Observer } from 'rxjs/Observer' ;
17
+ import { of } from 'rxjs/observable/of' ;
16
18
import { map } from 'rxjs/operator/map' ;
17
19
18
20
import { forEach } from '../src/utils/collection' ;
@@ -913,13 +915,12 @@ describe('Integration', () => {
913
915
{ provide : 'resolveFour' , useValue : ( a : any , b : any ) => 4 } ,
914
916
{ provide : 'resolveSix' , useClass : ResolveSix } ,
915
917
{ provide : 'resolveError' , useValue : ( a : any , b : any ) => Promise . reject ( 'error' ) } ,
916
- { provide : 'numberOfUrlSegments' , useValue : ( a : any , b : any ) => a . url . length }
918
+ { provide : 'numberOfUrlSegments' , useValue : ( a : any , b : any ) => a . url . length } ,
917
919
]
918
920
} ) ;
919
921
} ) ;
920
922
921
- it ( 'should provide resolved data' ,
922
- fakeAsync ( inject ( [ Router , Location ] , ( router : Router , location : Location ) => {
923
+ it ( 'should provide resolved data' , fakeAsync ( inject ( [ Router ] , ( router : Router ) => {
923
924
const fixture = createRoot ( router , RootCmpWithTwoOutlets ) ;
924
925
925
926
router . resetConfig ( [ {
@@ -1025,6 +1026,57 @@ describe('Integration', () => {
1025
1026
1026
1027
expect ( cmp . route . snapshot . data ) . toEqual ( { numberOfUrlSegments : 3 } ) ;
1027
1028
} ) ) ) ;
1029
+
1030
+ describe ( 'should run resolvers for the same route concurrently' , ( ) => {
1031
+ let log : string [ ] ;
1032
+ let observer : Observer < any > ;
1033
+
1034
+ beforeEach ( ( ) => {
1035
+ log = [ ] ;
1036
+ TestBed . configureTestingModule ( {
1037
+ providers : [
1038
+ {
1039
+ provide : 'resolver1' ,
1040
+ useValue : ( ) => {
1041
+ const obs$ = new Observable ( ( obs : Observer < any > ) => {
1042
+ observer = obs ;
1043
+ return ( ) => { } ;
1044
+ } ) ;
1045
+ return map . call ( obs$ , ( ) => log . push ( 'resolver1' ) ) ;
1046
+ }
1047
+ } ,
1048
+ {
1049
+ provide : 'resolver2' ,
1050
+ useValue : ( ) => {
1051
+ return map . call ( of ( null ) , ( ) => {
1052
+ log . push ( 'resolver2' ) ;
1053
+ observer . next ( null ) ;
1054
+ observer . complete ( )
1055
+ } ) ;
1056
+ }
1057
+ } ,
1058
+ ]
1059
+ } ) ;
1060
+ } ) ;
1061
+
1062
+ it ( 'works' , fakeAsync ( inject ( [ Router ] , ( router : Router ) => {
1063
+ const fixture = createRoot ( router , RootCmp ) ;
1064
+
1065
+ router . resetConfig ( [ {
1066
+ path : 'a' ,
1067
+ resolve : {
1068
+ one : 'resolver1' ,
1069
+ two : 'resolver2' ,
1070
+ } ,
1071
+ component : SimpleCmp
1072
+ } ] ) ;
1073
+
1074
+ router . navigateByUrl ( '/a' ) ;
1075
+ advance ( fixture ) ;
1076
+
1077
+ expect ( log ) . toEqual ( [ 'resolver2' , 'resolver1' ] ) ;
1078
+ } ) ) ) ;
1079
+ } ) ;
1028
1080
} ) ;
1029
1081
1030
1082
describe ( 'router links' , ( ) => {
0 commit comments