(
{
scrollPositionRestoration,
anchorScrolling,
}: {
scrollPositionRestoration: 'disabled' | 'enabled' | 'top';
anchorScrolling: 'disabled' | 'enabled';
},
extraProviders: any[] = [],
)
| 340 | }); |
| 341 | |
| 342 | function createRouterScroller( |
| 343 | { |
| 344 | scrollPositionRestoration, |
| 345 | anchorScrolling, |
| 346 | }: { |
| 347 | scrollPositionRestoration: 'disabled' | 'enabled' | 'top'; |
| 348 | anchorScrolling: 'disabled' | 'enabled'; |
| 349 | }, |
| 350 | extraProviders: any[] = [], |
| 351 | ) { |
| 352 | if (extraProviders.length > 0) { |
| 353 | TestBed.configureTestingModule({providers: extraProviders}); |
| 354 | } |
| 355 | |
| 356 | const events = new Subject<Event | PrivateRouterEvents>(); |
| 357 | (TestBed.inject(NavigationTransitions) as Writable<NavigationTransitions>).events = events; |
| 358 | |
| 359 | const viewportScroller = TestBed.inject(ViewportScroller); |
| 360 | spyOn(viewportScroller, 'getScrollPosition'); |
| 361 | spyOn(viewportScroller, 'scrollToPosition'); |
| 362 | spyOn(viewportScroller, 'scrollToAnchor'); |
| 363 | spyOn(viewportScroller, 'setHistoryScrollRestoration'); |
| 364 | setScroll(viewportScroller, 0, 0); |
| 365 | |
| 366 | const scroller = TestBed.runInInjectionContext( |
| 367 | () => new RouterScroller({scrollPositionRestoration, anchorScrolling}), |
| 368 | ); |
| 369 | scroller.init(); |
| 370 | |
| 371 | return {events, viewportScroller}; |
| 372 | } |
| 373 | |
| 374 | function setScroll(viewportScroller: any, x: number, y: number) { |
| 375 | viewportScroller.getScrollPosition.and.returnValue([x, y]); |
no test coverage detected
searching dependent graphs…