Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getAuthProvider(provider: string): {} {
var authProvider = {method: AuthMethods.Redirect};
switch (provider){
case 'Google': authProvider['provider'] = AuthProviders.Google; break;
case 'Github': authProvider['provider'] = AuthProviders.Github; break;
case 'Facebook': authProvider['provider'] = AuthProviders.Facebook; break;
case 'Twitter': authProvider['provider'] = AuthProviders.Twitter; break;
default: return '{}';
}
return authProvider;
}
private _getProvider(from: string) {
switch(from){
case 'twitter': return AuthProviders.Twitter;
case 'facebook': return AuthProviders.Facebook;
case 'github': return AuthProviders.Github;
case 'google': return AuthProviders.Google;
}
}
}
private _getProvider(from: string) {
switch (from) {
case 'twitter': return AuthProviders.Twitter;
case 'facebook': return AuthProviders.Facebook;
case 'github': return AuthProviders.Github;
case 'google': return AuthProviders.Google;
}
}
}
let deButtons = fixture.debugElement.queryAll(By.css('button'));
deButtons[0].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Google, 'Provider Google');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
deButtons[1].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Facebook, 'Provider Facebook');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
deButtons[2].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Twitter, 'Provider Twitter');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
deButtons[3].triggerEventHandler('click', null);
expect(af.auth.login).toHaveBeenCalled();
expect(spy.calls.mostRecent().args[0].provider).toBe(AuthProviders.Github, 'Provider Github');
expect(spy.calls.mostRecent().args[0].method).toBe(AuthMethods.Popup, 'Method Popup');
let spy2 = spyOn(dialog, "open")
.and.callFake((type: any, options: any) => {
expect(typeof type).toEqual("function");
expect(options.disableClose).toEqual(false);
});
deButtons[4].triggerEventHandler('click', null);
expect(spy2).toHaveBeenCalled();