diff options
Diffstat (limited to 'Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts')
-rw-r--r-- | Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts | 52 |
1 files changed, 2 insertions, 50 deletions
diff --git a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts index c56e1ed1..fbabdb1a 100644 --- a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts +++ b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts @@ -6,15 +6,6 @@ import { of, Observable } from 'rxjs'; import { delay } from 'rxjs/operators'; import { UserDialogComponent } from './user-dialog.component'; -import { createMockInternalUserService } from '../internal-user-service/internal-user.service.mock'; -import { InternalUserService, UserLoginState } from '../internal-user-service/internal-user.service'; - -@Component({ - /* tslint:disable-next-line:component-selector*/ - selector: 'mat-progress-spinner', - template: '' -}) -class MatProgressSpinnerStubComponent { } @Component({ /* tslint:disable-next-line:component-selector*/ @@ -27,16 +18,12 @@ class RouterOutletStubComponent { } describe('UserDialogComponent', () => { let component: UserDialogComponent; let fixture: ComponentFixture<UserDialogComponent>; - let mockInternalUserService: jasmine.SpyObj<InternalUserService>; beforeEach(async(() => { - mockInternalUserService = createMockInternalUserService(); - TestBed.configureTestingModule({ - declarations: [UserDialogComponent, MatProgressSpinnerStubComponent, RouterOutletStubComponent], - providers: [{ provide: InternalUserService, useValue: mockInternalUserService }, - { // for the workaround + declarations: [UserDialogComponent, RouterOutletStubComponent], + providers: [{ // for the workaround provide: Router, useValue: { events: new Observable<Event>() } @@ -50,39 +37,4 @@ describe('UserDialogComponent', () => { component = fixture.componentInstance; }); - it('progress spinner should work well', fakeAsync(() => { - mockInternalUserService.refreshAndGetUserState.and.returnValue(of(<UserLoginState>'nologin').pipe(delay(10))); - fixture.detectChanges(); - expect(fixture.debugElement.query(By.css('mat-progress-spinner'))).toBeTruthy(); - tick(10); - fixture.detectChanges(); - expect(fixture.debugElement.query(By.css('mat-progress-spinner'))).toBeFalsy(); - })); - - it('nologin should work well', () => { - mockInternalUserService.refreshAndGetUserState.and.returnValue(of(<UserLoginState>'nologin')); - - fixture.detectChanges(); - - expect(mockInternalUserService.refreshAndGetUserState).toHaveBeenCalled(); - expect(mockInternalUserService.userRouteNavigate).toHaveBeenCalledWith(['login', { reason: 'nologin' }]); - }); - - it('invalid login should work well', () => { - mockInternalUserService.refreshAndGetUserState.and.returnValue(of(<UserLoginState>'invalidlogin')); - - fixture.detectChanges(); - - expect(mockInternalUserService.refreshAndGetUserState).toHaveBeenCalled(); - expect(mockInternalUserService.userRouteNavigate).toHaveBeenCalledWith(['login', { reason: 'invalidlogin' }]); - }); - - it('success should work well', () => { - mockInternalUserService.refreshAndGetUserState.and.returnValue(of(<UserLoginState>'success')); - - fixture.detectChanges(); - - expect(mockInternalUserService.refreshAndGetUserState).toHaveBeenCalled(); - expect(mockInternalUserService.userRouteNavigate).toHaveBeenCalledWith(['success', { reason: 'already' }]); - }); }); |