import { TestBed } from '@angular/core/testing' ; import { DaffLoginInfo , DaffAuthToken , DaffAccountRegistration , } from '@daffodil/auth' ; import { DaffLoginServiceInterface } from '@daffodil/auth/driver' ; import { DaffAccountRegistrationFactory } from '@daffodil/auth/testing' ; import { DaffTestingLoginService } from './login.service' ; describe ( 'Driver | Testing | Auth | LoginService' , ( ) => { let loginService ; const registrationFactory = new DaffAccountRegistrationFactory ( ) ; let email ; let password ; let mockRegistration ; beforeEach ( ( ) => { TestBed . configureTestingModule ( { providers : [ DaffTestingLoginService , ] , } ) ; loginService = TestBed . inject ( DaffTestingLoginService ) ; mockRegistration = registrationFactory . create ( ) ; email = mockRegistration . customer . email ; password = mockRegistration . password ; } ) ; it ( 'should be created' , ( ) => { expect ( loginService ) . toBeTruthy ( ) ; } ) ; describe ( 'login | obtaining a token' , ( ) => { it ( 'should return a token' , done => { loginService . login ( { email , password } ) . subscribe ( auth => { expect ( auth . token ) . toBeTruthy ( ) ; done ( ) ; } ) ; } ) ; } ) ; describe ( 'logout | emitting undefined without error' , ( ) => { it ( 'should emit undefined without throwing an error' , done => { loginService . logout ( ) . subscribe ( auth => { expect ( auth ) . toBeUndefined ( ) ; done ( ) ; } ) ; } ) ; } ) ; } ) ;