Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it(`Should call the push method first time a login is successful`, () => {
let timesCalled = 0;
const subscription = spartacusEventTracker
.loginSuccessful()
.pipe(tap(_ => timesCalled++))
.subscribe();
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
subscription.unsubscribe();
expect(timesCalled).toEqual(2);
});
});
it(`Should call the push method first time a login is successful`, () => {
let timesCalled = 0;
const subscription = spartacusEventTracker
.loginSuccessful()
.pipe(tap(_ => timesCalled++))
.subscribe();
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGIN });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
mockActionsSubject.next({ type: AuthActions.LOGOUT });
subscription.unsubscribe();
expect(timesCalled).toEqual(2);
});
});
filter(action => action.type === AuthActions.LOGIN),
mapTo(true)
buildLoginEvent(): Observable {
return this.create([AuthActions.LOGIN]).pipe(
mapTo(true),
distinctUntilChanged()
);
}
action =>
action.type === AuthActions.LOGIN ||
action.type === AuthActions.LOGOUT
),