Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ngOnInit() {
this.subscription.add(
this.router.events
.startWith(new NavigationStart(42, '/configuration'))
.filter(e => e instanceof NavigationStart)
.filter((e: NavigationStart) => e.url === '/configuration')
.subscribe(e => {
this.router.navigate(['configuration/endpoints'])
}))
}
it('should not trigger ClearLightCardSelection if coming from somewhere else', () => {
const navigation = {
type: ROUTER_REQUEST,
payload: {
routerState: {
url: "/archive"
},
event: new NavigationStart(1,"/someOtherMenu")
}
}
const localActions$ = new Actions(hot('-a-', { a: navigation}));
const localExpected = hot('-');
effects = new CustomRouterEffects(mockStore, localActions$);
expect(effects).toBeTruthy();
expect(effects.navigateAwayFromFeed).toBeObservable(localExpected);
});
set eventParams(event) {
let nav;
if (event.nav === 'end') {
console.log('MY ONLY FRIEND THE END');
nav = new NavigationEnd(0, event.url, event.urlAfterRedirects);
} else {
nav = new NavigationStart(0, event.url);
}
this._eventParams = nav;
this.subject.next(nav);
}
function setVariables() {
getActiveBehavior = new BehaviorSubject('');
appendChildSpy = jasmine.createSpy('appendChildSpy');
getConsentBehavior = new BehaviorSubject([{}]);
routerEventsBehavior = new BehaviorSubject(
new NavigationStart(0, 'test.com', 'popstate')
);
debugBehavior = new ReplaySubject();
mockedWindowRef = {
nativeWindow: {
addEventListener: (_, listener) => {
eventListener = listener;
},
removeEventListener: jasmine.createSpy('removeEventListener'),
Y_TRACKING: {
push: jasmine.createSpy('push'),
},
},
document: {
createElement: () => ({}),
getElementsByTagName: () => [{ appendChild: appendChildSpy }],
},
beforeEach(() => {
const currentRoute = new NavigationStart(1, '/home');
routerEvents.next(currentRoute);
});
setup(skyAppConfig).then(() => {
fixture.detectChanges();
subscribeHandler(new NavigationStart(0, ''));
expect(scrollCalled).toBe(false);
subscribeHandler(new NavigationEnd(0, '', ''));
expect(scrollCalled).toBe(true);
});
}));
async(inject([Router], (router: RouterStub) => {
spyOn(comp.clearNotification, 'emit');
comp.notifications = [{
message: 'not found',
handle: '',
target: '',
type: '',
timer: 200,
scope: 'page',
clear: () => { },
}];
comp.ngOnChanges();
fixture.detectChanges();
const newRoute = new NavigationStart(2, '/home');
router.url = '/home';
routerEvents.next(newRoute);
fixture.detectChanges();
expect(comp.clearNotification.emit).not.toHaveBeenCalled();
}))
);
navigate(url: string) {
const navigationStart = new NavigationStart(0, url);
this.subject.next(navigationStart);
}
}
async(inject([Router], (router: RouterStub) => {
spyOn(comp.clearNotification, 'emit');
comp.notifications = [{
message: 'not found',
handle: '',
target: '',
type: '',
timer: 200,
scope: 'page',
clear: () => { },
}];
comp.ngOnChanges();
fixture.detectChanges();
const newRoute = new NavigationStart(2, '/home');
router.url = '/home';
routerEvents.next(newRoute);
fixture.detectChanges();
expect(comp.clearNotification.emit).not.toHaveBeenCalled();
}))
);