summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
diff options
context:
space:
mode:
authorIttay Stern <ittay.stern@att.com>2018-08-29 17:01:32 +0300
committerIttay Stern <ittay.stern@att.com>2019-02-18 18:35:30 +0200
commit6f900cc45d7dd7f97430812b86b5c1d1693c8ae3 (patch)
tree936005c364dc5a7264d6304d4777c3d83494db22 /vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
parent67d99f816cc583643c35193197594cf78d8ce60a (diff)
merge from ecomp a88f0072 - Modern UI
Issue-ID: VID-378 Change-Id: Ibcb23dd27f550cf32ce2fe0239f0f496ae014ff6 Signed-off-by: Ittay Stern <ittay.stern@att.com>
Diffstat (limited to 'vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts')
-rw-r--r--vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts118
1 files changed, 94 insertions, 24 deletions
diff --git a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
index c9f434e99..4848d8e99 100644
--- a/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
+++ b/vid-webpack-master/src/app/instantiationStatus/instantiationStatus.component.service.spec.ts
@@ -1,5 +1,6 @@
import {getTestBed, TestBed} from '@angular/core/testing';
import {
+ COMPLETED_WITH_ERRORS,
INPROGRESS,
InstantiationStatusComponentService,
PAUSE,
@@ -10,24 +11,64 @@ import {
X_O
} from './instantiationStatus.component.service';
import {ServiceInfoModel} from '../shared/server/serviceInfo/serviceInfo.model';
-import { Observable } from 'rxjs/Rx';
+import {AaiService} from "../shared/services/aaiService/aai.service";
+import {MsoService} from "../shared/services/msoService/mso.service";
+import {NgRedux} from "@angular-redux/store";
+import {HttpClientTestingModule} from "@angular/common/http/testing";
+import {FeatureFlagsService} from "../shared/services/featureFlag/feature-flags.service";
+import {DrawingBoardModes} from "../drawingBoard/service-planning/drawing-board.modes";
+import {RouterTestingModule} from "@angular/router/testing";
+import {of} from "rxjs";
+import {UrlTree} from "@angular/router";
+class MockAppStore<T> {
+
+ getState() {
+ return {
+ global: {
+ flags: {
+ 'FLAG_1902_NEW_VIEW_EDIT': true,
+
+ }
+ }
+ }
+ }
+
+ dispatch() {
+
+ }
+}
describe('Instantiation Status Service', () => {
let injector;
+ let aaiService: AaiService;
+ let msoService: MsoService;
let service: InstantiationStatusComponentService;
- beforeEach(() => {
+
+ beforeAll(done => (async () => {
TestBed.configureTestingModule({
- imports: [],
- providers: [InstantiationStatusComponentService]
+ imports: [
+ HttpClientTestingModule,
+ RouterTestingModule,
+ ],
+ providers: [
+ InstantiationStatusComponentService,
+ AaiService,
+ MsoService,
+ FeatureFlagsService,
+ {provide: NgRedux, useClass: MockAppStore}]
});
+ await TestBed.compileComponents();
injector = getTestBed();
+ aaiService = injector.get(AaiService);
+ msoService = injector.get(MsoService);
service = injector.get(InstantiationStatusComponentService);
- });
- it('generateServiceInfoDataMapping should return mapping of arrays', (done: DoneFn) => {
- let data : Array<ServiceInfoModel> = generateServiceInfoData();
+ })().then(done).catch(done.fail));
+
+ test('generateServiceInfoDataMapping should return mapping of arrays', () => {
+ let data : ServiceInfoModel[] = generateServiceInfoData();
let result = service.generateServiceInfoDataMapping(data);
expect(result['1']).toBeDefined();
@@ -37,53 +78,81 @@ describe('Instantiation Status Service', () => {
expect(result['1'].length).toEqual(2);
expect(result['2'].length).toEqual(2);
expect(result['3'].length).toEqual(1);
- done();
});
- it('generateServiceInfoDataMapping if array is empty should return empty object', (done: DoneFn) => {
+ test('generateServiceInfoDataMapping if array is empty should return empty object', () => {
let result = service.generateServiceInfoDataMapping([]);
expect(result['1']).not.toBeDefined();
expect(result['2']).not.toBeDefined();
expect(result['3']).not.toBeDefined();
- done();
});
- it('convertObjectToArray', (done: DoneFn) => {
+ test('convertObjectToArray', () => {
- spyOn(service, 'convertObjectToArray').and.returnValue(
- Observable.of([])
+ jest.spyOn(service, 'convertObjectToArray').mockReturnValue(
+ of([])
);
- let data : Array<ServiceInfoModel> = generateServiceInfoData();
+ let data : ServiceInfoModel[] = generateServiceInfoData();
service.convertObjectToArray(data).subscribe((result) => {
expect(result).toBeDefined();
- done();
});
});
- it('getStatusTooltip should return status popover', (done: DoneFn) => {
+ test('click on "Open" button should open new view edit' , ()=>{
+ const item = {
+ serviceModelId : 'serviceModelId',
+ serviceInstanceId : 'serviceInstanceId',
+ serviceType : 'serviceType',
+ subscriberId : 'subscriberId'
+ };
+ let params:UrlTree = service.getNewViewEditUrlTree(item, DrawingBoardModes.VIEW);
+ expect(params.toString().startsWith('/servicePlanning/VIEW')).toBeTruthy();
+ expect(params.queryParams).toEqual(
+ {
+ serviceModelId: item.serviceModelId,
+ serviceInstanceId: item.serviceInstanceId,
+ serviceType : item.serviceType,
+ subscriberId : item.subscriberId
+ });
+ });
+
+ test('build the View Edit url' , ()=>{
+ const item = {
+ serviceModelId : '28aeb8f6-5620-4148-8bfb-a5fb406f0309',
+ };
+ let serviceModelUrl: string = '/servicePlanning/EDIT?serviceModelId=28aeb8f6-5620-4148-8bfb-a5fb406f0309';
+ let suffix:string = '../../serviceModels.htm#';
+ let tree:UrlTree = service.getNewViewEditUrlTree(item, DrawingBoardModes.EDIT);
+ let result = service.getViewEditUrl(tree);
+ expect (suffix + serviceModelUrl).toEqual(result);
+ });
+
+ test('getStatusTooltip should return status popover', () => {
let result : ServiceStatus = service.getStatus('pending');
- expect(result.tooltip).toEqual('Pending: The service will automatically be sent for instantiation as soon as possible.');
+ expect(result.tooltip).toEqual('Pending: The action required will be sent as soon as possible.');
result = service.getStatus('IN_PROGRESS');
- expect(result.tooltip).toEqual('In-progress: the service is in process of instantiation.');
+ expect(result.tooltip).toEqual('In-progress: the service is in process of the action required.');
result = service.getStatus('PAUSED');
expect(result.tooltip).toEqual('Paused: Service has paused and waiting for your action.\n Select actions from the menu to the right.');
result = service.getStatus('FAILED');
- expect(result.tooltip).toEqual('Failed: Service instantiation has failed, load the service to see the error returned.');
+ expect(result.tooltip).toEqual('Failed: All planned actions have failed.');
result = service.getStatus('COMPLETED');
- expect(result.tooltip).toEqual('Completed successfully: Service is successfully instantiated.');
+ expect(result.tooltip).toEqual('Completed successfully: Service is successfully instantiated, updated or deleted.');
result = service.getStatus('STOPPED');
expect(result.tooltip).toEqual('Stopped: Due to previous failure, will not be instantiated.');
- done();
+
+ result = service.getStatus('COMPLETED_WITH_ERRORS');
+ expect(result.tooltip).toEqual('Completed with errors: some of the planned actions where successfully committed while other have not.\n Open the service to check it out.');
});
- it('getStatusTooltip should return correct icon per job status', (done: DoneFn) => {
+ test('getStatusTooltip should return correct icon per job status', () => {
let result : ServiceStatus = service.getStatus('pending');
expect(result.iconClassName).toEqual(PENDING);
@@ -101,9 +170,10 @@ describe('Instantiation Status Service', () => {
result = service.getStatus('STOPPED');
expect(result.iconClassName).toEqual(STOPED);
- done();
- });
+ result = service.getStatus('COMPLETED_WITH_ERRORS');
+ expect(result.iconClassName).toEqual(COMPLETED_WITH_ERRORS);
+ });
function generateServiceInfoData(){
return JSON.parse(JSON.stringify([