diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.core.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.core.spec.ts index b741afcad84..ad08621b677 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.core.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.core.spec.ts @@ -1,41 +1,43 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { AmazonSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/amazon-sign-in-component/amazon-sign-in.component.core' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { AmazonSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/amazon-sign-in-component/amazon-sign-in.component.core'; import Amplify from 'aws-amplify'; describe('AmazonSignInComponentCore (basics): ', () => { + let component: AmazonSignInComponentCore; + let service: AmplifyService; - let component: AmazonSignInComponentCore; - let service: AmplifyService; + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new AmazonSignInComponentCore(service); + }); - beforeEach(() => { - service = new AmplifyService(); - component = new AmazonSignInComponentCore(service); - }); + afterEach(() => { + service = null; + component = null; + }); - afterEach(() => { - service = null; - component = null; - }); - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); - it('...should have a onSignIn method', () => { - expect(component.onSignIn).toBeTruthy(); - }); - it('...should have a initAmazon method', () => { - expect(component.initAmazon).toBeTruthy(); - }); - it('...should have a amazonAuthorize method', () => { - expect(component.amazonAuthorize).toBeTruthy(); - }); - it('...should have a amazonRetrieveProfile method', () => { - expect(component.amazonRetrieveProfile).toBeTruthy(); - }); - it('...should have a createScript method', () => { - expect(component.createScript).toBeTruthy(); - }); -}); \ No newline at end of file + it('...should be created', () => { + expect(component).toBeTruthy(); + }); + it('...should have a onSignIn method', () => { + expect(component.onSignIn).toBeTruthy(); + }); + it('...should have a initAmazon method', () => { + expect(component.initAmazon).toBeTruthy(); + }); + it('...should have a amazonAuthorize method', () => { + expect(component.amazonAuthorize).toBeTruthy(); + }); + it('...should have a amazonRetrieveProfile method', () => { + expect(component.amazonRetrieveProfile).toBeTruthy(); + }); + it('...should have a createScript method', () => { + expect(component.createScript).toBeTruthy(); + }); +}); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.ionic.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.ionic.spec.ts index a512b61a6e9..c578e2cd6d9 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.ionic.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/amazon-sign-in.component.ionic.spec.ts @@ -1,41 +1,43 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { AmazonSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/amazon-sign-in-component/amazon-sign-in.component.ionic' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { AmazonSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/amazon-sign-in-component/amazon-sign-in.component.ionic'; import Amplify from 'aws-amplify'; describe('AmazonSignInComponentIonic (basics): ', () => { + let component: AmazonSignInComponentIonic; + let service: AmplifyService; - let component: AmazonSignInComponentIonic; - let service: AmplifyService; + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new AmazonSignInComponentIonic(service); + }); - beforeEach(() => { - service = new AmplifyService(); - component = new AmazonSignInComponentIonic(service); - }); + afterEach(() => { + service = null; + component = null; + }); - afterEach(() => { - service = null; - component = null; - }); - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); - it('...should have a onSignIn method', () => { - expect(component.onSignIn).toBeTruthy(); - }); - it('...should have a initAmazon method', () => { - expect(component.initAmazon).toBeTruthy(); - }); - it('...should have a amazonAuthorize method', () => { - expect(component.amazonAuthorize).toBeTruthy(); - }); - it('...should have a amazonRetrieveProfile method', () => { - expect(component.amazonRetrieveProfile).toBeTruthy(); - }); - it('...should have a createScript method', () => { - expect(component.createScript).toBeTruthy(); - }); -}); \ No newline at end of file + it('...should be created', () => { + expect(component).toBeTruthy(); + }); + it('...should have a onSignIn method', () => { + expect(component.onSignIn).toBeTruthy(); + }); + it('...should have a initAmazon method', () => { + expect(component.initAmazon).toBeTruthy(); + }); + it('...should have a amazonAuthorize method', () => { + expect(component.amazonAuthorize).toBeTruthy(); + }); + it('...should have a amazonRetrieveProfile method', () => { + expect(component.amazonRetrieveProfile).toBeTruthy(); + }); + it('...should have a createScript method', () => { + expect(component.createScript).toBeTruthy(); + }); +}); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.core.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.core.spec.ts index ed7bf180ecf..548dea98db5 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.core.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.core.spec.ts @@ -1,45 +1,46 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { FacebookSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/facebook-sign-in-component/facebook-sign-in.component.core' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { FacebookSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/facebook-sign-in-component/facebook-sign-in.component.core'; import Amplify from 'aws-amplify'; describe('FacebookSignInComponentCore (basics): ', () => { + let component: FacebookSignInComponentCore; + let service: AmplifyService; - let component: FacebookSignInComponentCore; - let service: AmplifyService; + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new FacebookSignInComponentCore(service); + }); - beforeEach(() => { - service = new AmplifyService(); - component = new FacebookSignInComponentCore(service); - }); + afterEach(() => { + service = null; + component = null; + }); - afterEach(() => { - service = null; - component = null; - }); - - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); - it('...should have a onSignIn method', () => { - expect(component.onSignIn).toBeTruthy(); - }); - it('...should have a facebookApi method', () => { - expect(component.facebookApi).toBeTruthy(); - }); - it('...should have a facebookLoginStatus method', () => { - expect(component.facebookLoginStatus).toBeTruthy(); - }); - it('...should have a facebookLogin method', () => { - expect(component.facebookLogin).toBeTruthy(); - }); - it('...should have a fbAsyncInit method', () => { - expect(component.fbAsyncInit).toBeTruthy(); - }); - it('...should have a createScript method', () => { - expect(component.createScript).toBeTruthy(); - }); -}); \ No newline at end of file + it('...should be created', () => { + expect(component).toBeTruthy(); + }); + it('...should have a onSignIn method', () => { + expect(component.onSignIn).toBeTruthy(); + }); + it('...should have a facebookApi method', () => { + expect(component.facebookApi).toBeTruthy(); + }); + it('...should have a facebookLoginStatus method', () => { + expect(component.facebookLoginStatus).toBeTruthy(); + }); + it('...should have a facebookLogin method', () => { + expect(component.facebookLogin).toBeTruthy(); + }); + it('...should have a fbAsyncInit method', () => { + expect(component.fbAsyncInit).toBeTruthy(); + }); + it('...should have a createScript method', () => { + expect(component.createScript).toBeTruthy(); + }); +}); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.ionic.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.ionic.spec.ts index 962b0f51f62..bb8f2cf528c 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.ionic.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/facebook-sign-in.component.ionic.spec.ts @@ -1,45 +1,46 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { FacebookSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/facebook-sign-in-component/facebook-sign-in.component.ionic' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { FacebookSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/facebook-sign-in-component/facebook-sign-in.component.ionic'; import Amplify from 'aws-amplify'; describe('FacebookSignInComponentIonic (basics): ', () => { + let component: FacebookSignInComponentIonic; + let service: AmplifyService; - let component: FacebookSignInComponentIonic; - let service: AmplifyService; + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new FacebookSignInComponentIonic(service); + }); - beforeEach(() => { - service = new AmplifyService(); - component = new FacebookSignInComponentIonic(service); - }); + afterEach(() => { + service = null; + component = null; + }); - afterEach(() => { - service = null; - component = null; - }); - - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); - it('...should have a onSignIn method', () => { - expect(component.onSignIn).toBeTruthy(); - }); - it('...should have a facebookApi method', () => { - expect(component.facebookApi).toBeTruthy(); - }); - it('...should have a facebookLoginStatus method', () => { - expect(component.facebookLoginStatus).toBeTruthy(); - }); - it('...should have a facebookLogin method', () => { - expect(component.facebookLogin).toBeTruthy(); - }); - it('...should have a fbAsyncInit method', () => { - expect(component.fbAsyncInit).toBeTruthy(); - }); - it('...should have a createScript method', () => { - expect(component.createScript).toBeTruthy(); - }); -}); \ No newline at end of file + it('...should be created', () => { + expect(component).toBeTruthy(); + }); + it('...should have a onSignIn method', () => { + expect(component.onSignIn).toBeTruthy(); + }); + it('...should have a facebookApi method', () => { + expect(component.facebookApi).toBeTruthy(); + }); + it('...should have a facebookLoginStatus method', () => { + expect(component.facebookLoginStatus).toBeTruthy(); + }); + it('...should have a facebookLogin method', () => { + expect(component.facebookLogin).toBeTruthy(); + }); + it('...should have a fbAsyncInit method', () => { + expect(component.fbAsyncInit).toBeTruthy(); + }); + it('...should have a createScript method', () => { + expect(component.createScript).toBeTruthy(); + }); +}); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.core.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.core.spec.ts index 8e8242e56c4..bc8dffee479 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.core.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.core.spec.ts @@ -1,27 +1,28 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { FederatedSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/federated-sign-in.component.core' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { FederatedSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/federated-sign-in.component.core'; import Amplify from 'aws-amplify'; describe('FederatedSignInComponentCore (basics): ', () => { + let component: FederatedSignInComponentCore; + let service: AmplifyService; - let component: FederatedSignInComponentCore; - let service: AmplifyService; + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new FederatedSignInComponentCore(service); + }); - beforeEach(() => { - service = new AmplifyService(); - component = new FederatedSignInComponentCore(service); - }); + afterEach(() => { + service = null; + component = null; + }); - afterEach(() => { - service = null; - component = null; - }); - - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); -}); \ No newline at end of file + it('...should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.ionic.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.ionic.spec.ts index 93fe48fc408..de43f6c6501 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.ionic.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/federated-sign-in.component.ionic.spec.ts @@ -1,27 +1,28 @@ import { Component } from '@angular/core'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { FederatedSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/federated-sign-in.component.ionic' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { FederatedSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/federated-sign-in.component.ionic'; import Amplify from 'aws-amplify'; describe('FederatedSignInComponentIonic (basics): ', () => { + let component: FederatedSignInComponentIonic; + let service: AmplifyService; - let component: FederatedSignInComponentIonic; - let service: AmplifyService; + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new FederatedSignInComponentIonic(service); + }); - beforeEach(() => { - service = new AmplifyService(); - component = new FederatedSignInComponentIonic(service); - }); + afterEach(() => { + service = null; + component = null; + }); - afterEach(() => { - service = null; - component = null; - }); - - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); -}); \ No newline at end of file + it('...should be created', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.core.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.core.spec.ts index 7d9c7763046..84605a0c5d2 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.core.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.core.spec.ts @@ -1,40 +1,41 @@ import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { GoogleSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/google-sign-in-component/google-sign-in.component.core' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; import Amplify from 'aws-amplify'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { GoogleSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/google-sign-in-component/google-sign-in.component.core'; describe('GoogleSignInComponentCore (basics): ', () => { - - let component: GoogleSignInComponentCore; - let service: AmplifyService; - - beforeEach(() => { - service = new AmplifyService(); - component = new GoogleSignInComponentCore(service); - }); - - afterEach(() => { - service = null; - component = null; - }); - - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); - - it('...should have a onSignIn method', () => { - expect(component.onSignIn).toBeTruthy(); - }); - - it('...should have a createScript method', () => { - expect(component.createScript).toBeTruthy(); - }); - - it('...should have a initGapi method', () => { - expect(component.initGapi).toBeTruthy(); - }); + let component: GoogleSignInComponentCore; + let service: AmplifyService; + + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new GoogleSignInComponentCore(service); + }); + + afterEach(() => { + service = null; + component = null; + }); + + it('...should be created', () => { + expect(component).toBeTruthy(); + }); + + it('...should have a onSignIn method', () => { + expect(component.onSignIn).toBeTruthy(); + }); + + it('...should have a createScript method', () => { + expect(component.createScript).toBeTruthy(); + }); + + it('...should have a initGapi method', () => { + expect(component.initGapi).toBeTruthy(); + }); }); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.ionic.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.ionic.spec.ts index 754c807139f..d87ee1d0fd9 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.ionic.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/google-sign-in.component.ionic.spec.ts @@ -1,40 +1,41 @@ import { Component } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { ComponentFixture, TestBed } from '@angular/core/testing'; -import { BrowserDynamicTestingModule, platformBrowserDynamicTesting } from '@angular/platform-browser-dynamic/testing'; -import { AmplifyService } from '../../../providers/amplify.service' -import { GoogleSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/google-sign-in-component/google-sign-in.component.ionic' +import { + BrowserDynamicTestingModule, + platformBrowserDynamicTesting, +} from '@angular/platform-browser-dynamic/testing'; +import { AmplifyService } from '../../../providers/amplify.service'; +import { GoogleSignInComponentIonic } from '../../../components/authenticator/federated-sign-in-component/google-sign-in-component/google-sign-in.component.ionic'; import Amplify from 'aws-amplify'; describe('GoogleSignInComponentIonic (basics): ', () => { - - let component: GoogleSignInComponentIonic; - let service: AmplifyService; - - beforeEach(() => { - service = new AmplifyService(); - component = new GoogleSignInComponentIonic(service); - }); - - afterEach(() => { - service = null; - component = null; - }); - - - it('...should be created', () => { - expect(component).toBeTruthy(); - }); - - it('...should have a onSignIn method', () => { - expect(component.onSignIn).toBeTruthy(); - }); - - it('...should have a createScript method', () => { - expect(component.createScript).toBeTruthy(); - }); - - it('...should have a initGapi method', () => { - expect(component.initGapi).toBeTruthy(); - }); + let component: GoogleSignInComponentIonic; + let service: AmplifyService; + + beforeEach(() => { + service = new AmplifyService(Amplify); + component = new GoogleSignInComponentIonic(service); + }); + + afterEach(() => { + service = null; + component = null; + }); + + it('...should be created', () => { + expect(component).toBeTruthy(); + }); + + it('...should have a onSignIn method', () => { + expect(component.onSignIn).toBeTruthy(); + }); + + it('...should have a createScript method', () => { + expect(component.createScript).toBeTruthy(); + }); + + it('...should have a initGapi method', () => { + expect(component.initGapi).toBeTruthy(); + }); }); diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-in.component.core.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-in.component.core.spec.ts index b3388c52e50..451e2c9fa81 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-in.component.core.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-in.component.core.spec.ts @@ -10,6 +10,7 @@ import { AmplifyService, AmplifyModules } from '../../../providers'; import { authModule } from '../../../__mocks__/mock_module'; import { SignInComponentCore } from '../../../components/authenticator/sign-in-component/sign-in.component.core'; import { UsernameFieldComponentCore } from '../../../components/authenticator/username-field-component/username-field.component.core'; +import { FederatedSignInComponentCore } from '../../../components/authenticator/federated-sign-in-component/federated-sign-in.component.core'; describe('SignInComponentCore: ', () => { let component: SignInComponentCore; @@ -29,6 +30,7 @@ describe('SignInComponentCore: ', () => { declarations: [ SignInComponentCore, MockComponent(UsernameFieldComponentCore), + MockComponent(FederatedSignInComponentCore), ], providers: [ { diff --git a/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-up.component.core.spec.ts b/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-up.component.core.spec.ts index 700c2a53ff3..6d931fd4416 100644 --- a/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-up.component.core.spec.ts +++ b/packages/aws-amplify-angular/src/__tests__/components/authenticator/sign-up.component.core.spec.ts @@ -14,7 +14,6 @@ import { SignUpField, } from '../../../components/authenticator/sign-up-component/sign-up.component.core'; import { PhoneFieldComponentCore } from '../../../components/authenticator/phone-field-component/phone-field.component.core'; -// tslint:enable describe('SignUpComponentCore (basics): ', () => { let component: SignUpComponentCore; diff --git a/packages/aws-amplify-angular/src/components/authenticator/federated-sign-in-component/federated-sign-in.component.core.ts b/packages/aws-amplify-angular/src/components/authenticator/federated-sign-in-component/federated-sign-in.component.core.ts index 41ce83f2c59..2ad46112e27 100644 --- a/packages/aws-amplify-angular/src/components/authenticator/federated-sign-in-component/federated-sign-in.component.core.ts +++ b/packages/aws-amplify-angular/src/components/authenticator/federated-sign-in-component/federated-sign-in.component.core.ts @@ -23,12 +23,10 @@ const template = ` *ngIf="googleClientId" [googleClientId]="googleClientId" > - - -` +`; @Component({ - selector: 'amplify-auth-google-sign-in-core', - template + selector: 'amplify-auth-google-sign-in-core', + template, }) export class GoogleSignInComponentCore implements OnInit { - @Input() googleClientId: string; - protected logger: any; - amplifyUI: any; + @Input() googleClientId: string; + protected logger: any; + amplifyUI: any; - constructor(protected amplifyService: AmplifyService) { - this.logger = this.amplifyService.logger('GoogleSignInComponent', 'INFO'); - this.amplifyUI = AmplifyUI - } + constructor(protected amplifyService: AmplifyService) { + this.logger = this.amplifyService.logger('GoogleSignInComponent', 'INFO'); + this.amplifyUI = AmplifyUI; + } - ngOnInit() { - if (!this.amplifyService.auth() || - typeof this.amplifyService.auth().federatedSignIn !== 'function' || - typeof this.amplifyService.auth().currentAuthenticatedUser !== 'function') { - this.logger.warn('No Auth module found, please ensure @aws-amplify/auth is imported'); - } + ngOnInit() { + if ( + !this.amplifyService.auth() || + typeof this.amplifyService.auth().federatedSignIn !== 'function' || + typeof this.amplifyService.auth().currentAuthenticatedUser !== 'function' + ) { + this.logger.warn( + 'No Auth module found, please ensure @aws-amplify/auth is imported' + ); + } - const ga = (window).gapi && (window).gapi.auth2 - ? (window).gapi.auth2.getAuthInstance() - : null; - if (this.googleClientId && !ga) { - this.createScript(); - } - } + const ga = + (window).gapi && (window).gapi.auth2 + ? (window).gapi.auth2.getAuthInstance() + : null; + if (this.googleClientId && !ga) { + this.createScript(); + } + } - async onSignIn() { - const ga = (window).gapi.auth2.getAuthInstance(); - try { - const googleUser = await ga.signIn() - const { id_token, expires_at } = googleUser.getAuthResponse(); - const profile = googleUser.getBasicProfile(); - const gapiUser = { - email: profile.getEmail(), - name: profile.getName(), - picture: profile.getImageUrl(), - }; + async onSignIn() { + const ga = (window).gapi.auth2.getAuthInstance(); + try { + const googleUser = await ga.signIn(); + const { id_token, expires_at } = googleUser.getAuthResponse(); + const profile = googleUser.getBasicProfile(); + const gapiUser = { + email: profile.getEmail(), + name: profile.getName(), + picture: profile.getImageUrl(), + }; - const payload = { provider: constants.GOOGLE }; - setLocalStorage(constants.AUTH_SOURCE_KEY, payload, this.logger); + const payload = { provider: constants.GOOGLE }; + setLocalStorage(constants.AUTH_SOURCE_KEY, payload, this.logger); - await this.amplifyService.auth().federatedSignIn('google', { - token: id_token, - expires_at - }, gapiUser); - this.logger.debug(`Signed in with federated identity: ${constants.GOOGLE}`); - - const user = await this.amplifyService.auth().currentAuthenticatedUser(); - this.amplifyService.setAuthState({ state: 'signedIn', user: user}); - } catch(error) { - this.logger.error(error); - } - } + await this.amplifyService.auth().federatedSignIn( + 'google', + { + token: id_token, + expires_at, + }, + gapiUser + ); + this.logger.debug( + `Signed in with federated identity: ${constants.GOOGLE}` + ); - initGapi() { - this.logger.debug('init gapi'); - const ga = (window).gapi; - const self = this; - ga.load('auth2', () => { - ga.auth2.init({ - client_id: self.googleClientId, - scope: 'profile email openid' - }); - }); - } + const user = await this.amplifyService.auth().currentAuthenticatedUser(); + this.amplifyService.setAuthState({ state: 'signedIn', user: user }); + } catch (error) { + this.logger.error(error); + } + } - createScript() { - const script = document.createElement('script'); - - script.src = 'https://apis.google.com/js/platform.js'; - script.async = true; - script.onload = this.initGapi.bind(this) - document.body.appendChild(script); - } + initGapi() { + this.logger.debug('init gapi'); + const ga = (window).gapi; + const self = this; + ga.load('auth2', () => { + ga.auth2.init({ + client_id: self.googleClientId, + scope: 'profile email openid', + }); + }); + } + + createScript() { + const script = document.createElement('script'); + + script.src = 'https://apis.google.com/js/platform.js'; + script.async = true; + script.onload = this.initGapi.bind(this); + document.body.appendChild(script); + } } diff --git a/packages/aws-amplify-angular/src/components/authenticator/sign-in-component/sign-in.component.core.ts b/packages/aws-amplify-angular/src/components/authenticator/sign-in-component/sign-in.component.core.ts index c95996c73b4..42d9462080e 100644 --- a/packages/aws-amplify-angular/src/components/authenticator/sign-in-component/sign-in.component.core.ts +++ b/packages/aws-amplify-angular/src/components/authenticator/sign-in-component/sign-in.component.core.ts @@ -27,7 +27,7 @@ const template = `
{{ this.amplifyService.i18n().get('Sign in to your account') }}
-
+
{{ this.amplifyService.i18n().get('Sign in to your account') }}
-
+