aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts
diff options
context:
space:
mode:
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.ts59
1 files changed, 7 insertions, 52 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..47860eee 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
@@ -1,20 +1,10 @@
import { Component } from '@angular/core';
-import { async, ComponentFixture, TestBed, fakeAsync, tick } from '@angular/core/testing';
-import { By } from '@angular/platform-browser';
+import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { Router, Event } from '@angular/router';
-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';
+import { Observable } from 'rxjs';
-@Component({
- /* tslint:disable-next-line:component-selector*/
- selector: 'mat-progress-spinner',
- template: ''
-})
-class MatProgressSpinnerStubComponent { }
+import { UserDialogComponent } from './user-dialog.component';
@Component({
/* tslint:disable-next-line:component-selector*/
@@ -27,16 +17,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>()
}
@@ -48,41 +34,10 @@ describe('UserDialogComponent', () => {
beforeEach(() => {
fixture = TestBed.createComponent(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' }]);
+ it('should create', () => {
+ expect(component).toBeTruthy();
});
});