Summary Table

Categories Total Count
PII 0
URL 0
DNS 0
EKL 0
IP 0
PORT 0
VsID 0
CF 0
AI 1
VPD 0
PL 0
Other 0

File Content

import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';

import { FormBuilder } from '@angular/forms';
import { AuthenticationService } from '../../auth/auth.service';
import { HeaderComponent } from './header.component';
import { EwvViewerService } from '../../ewv/ewv-viewer/ewv-viewer.service';

describe('HeaderComponent', () => {
let component: HeaderComponent;
let router;
let location;
let authenticationService: AuthenticationService;
let ewvViewerService: EwvViewerService;

beforeEach(() => {
router = { navigate: () => true };
location = { replaceState: () => true };
authenticationService = new AuthenticationService(null, null, null, null);
ewvViewerService = new EwvViewerService(null, null);

component = new HeaderComponent(authenticationService, ewvViewerService);
});

it('should be created', () => {
expect(component).toBeTruthy(); // Expects component to be created
});

it('test ngOnInit method: "authenticationService.getDecodedUserInfo" returns back object that has "userName" property with non-white space string', () => {
expect(component.userName).toEqual('');

let returnedData = { userName:
AI };
spyOn(authenticationService, 'getDecodedUserInfo').and.callFake(
() => returnedData
);

component.ngOnInit();

expect(component.userName).toEqual('USER_NAME');
});

it('test ngOnInit method: "authenticationService.getDecodedUserInfo" returns back object that has no "userName" property', () => {
expect(component.userName).toEqual('');

let returnedData = {};
spyOn(authenticationService, 'getDecodedUserInfo').and.callFake(
() => returnedData
);

component.ngOnInit();

expect(component.userName).toEqual(undefined);
});

// it('test logout method', () => {
// spyOn(sessionStorage, 'clear');
// spyOn(location, 'replaceState');
// spyOn(router, 'navigate');

// component.logout();

// expect(sessionStorage.clear).toHaveBeenCalled();
// expect(location.replaceState).toHaveBeenCalled();
// expect(location.replaceState).toHaveBeenCalledWith('/');
// expect(router.navigate).toHaveBeenCalled();
// expect(router.navigate).toHaveBeenCalledWith(['/login']);
// });
});