aboutsummaryrefslogtreecommitdiff
path: root/Timeline/ClientApp/src/app/user/user-dialog
diff options
context:
space:
mode:
Diffstat (limited to 'Timeline/ClientApp/src/app/user/user-dialog')
-rw-r--r--Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.css5
-rw-r--r--Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.html5
-rw-r--r--Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.spec.ts52
-rw-r--r--Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts23
4 files changed, 6 insertions, 79 deletions
diff --git a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.css b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.css
index a443e3c0..e69de29b 100644
--- a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.css
+++ b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.css
@@ -1,5 +0,0 @@
-.container {
- display: flex;
- justify-content: center;
- align-content: center;
-}
diff --git a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.html b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.html
index 58dff0e4..e8dbb003 100644
--- a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.html
+++ b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.html
@@ -1,4 +1 @@
-<div class="container">
- <mat-progress-spinner *ngIf="isLoading" mode="indeterminate" diameter="50"></mat-progress-spinner>
- <router-outlet name="user"></router-outlet>
-</div>
+<router-outlet name="user"></router-outlet>
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' }]);
- });
});
diff --git a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts
index cf5f3643..2887f0a6 100644
--- a/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts
+++ b/Timeline/ClientApp/src/app/user/user-dialog/user-dialog.component.ts
@@ -1,5 +1,4 @@
-import { Component, OnInit, OnDestroy, ViewChild } from '@angular/core';
-import { InternalUserService } from '../internal-user-service/internal-user.service';
+import { Component, OnInit, ViewChild } from '@angular/core';
import { RouterOutlet, Router, ActivationStart } from '@angular/router';
@Component({
@@ -7,14 +6,12 @@ import { RouterOutlet, Router, ActivationStart } from '@angular/router';
templateUrl: './user-dialog.component.html',
styleUrls: ['./user-dialog.component.css']
})
-export class UserDialogComponent implements OnInit, OnDestroy {
+export class UserDialogComponent implements OnInit {
- constructor(private userService: InternalUserService, private router: Router) { }
+ constructor(private router: Router) { }
@ViewChild(RouterOutlet) outlet!: RouterOutlet;
- isLoading = true;
-
ngOnInit() {
// this is a workaround for a bug. see https://github.com/angular/angular/issues/20694
const subscription = this.router.events.subscribe(e => {
@@ -23,19 +20,5 @@ export class UserDialogComponent implements OnInit, OnDestroy {
subscription.unsubscribe();
}
});
-
-
- this.userService.refreshAndGetUserState().subscribe(result => {
- this.isLoading = false;
- if (result === 'success') {
- this.userService.userRouteNavigate(['success', { reason: 'already' }]);
- } else {
- this.userService.userRouteNavigate(['login', { reason: result }]);
- }
- });
- }
-
- ngOnDestroy() {
- this.userService.userRouteNavigate(null);
}
}