NodeInfo::getModel expects the instance-model
[vid.git] / vid-webpack-master / src / app / drawingBoard / service-planning / objectsToTree / models / collectionResource / collectionResource.model.info.spec.ts
1 import {HttpClientTestingModule} from "@angular/common/http/testing";
2 import {getTestBed, TestBed} from "@angular/core/testing";
3 import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing";
4 import {DynamicInputsService} from "../../dynamicInputs.service";
5 import {SharedTreeService} from "../../shared.tree.service";
6 import {NgRedux} from "@angular-redux/store";
7 import {AppState} from "../../../../../shared/store/reducers";
8 import {DuplicateService} from "../../../duplicate/duplicate.service";
9 import {IframeService} from "../../../../../shared/utils/iframe.service";
10 import {ComponentInfoService} from "../../../component-info/component-info.service";
11 import {AaiService} from "../../../../../shared/services/aaiService/aai.service";
12 import {HttpClient, HttpHandler} from "@angular/common/http";
13 import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/feature-flags.service";
14 import {CollectionResourceModelInfo} from "./collectionResource.model.info";
15 import {ComponentInfoType} from "../../../component-info/component-info-model";
16 import {CollectionResourceModel} from "../../../../../shared/models/collectionResourceModel";
17 import {NcfModelInfo} from "../ncf/ncf.model.info";
18
19 describe('Collection Resource Model Info', () => {
20   let injector;
21   let _componentInfoService : ComponentInfoService;
22
23   let _store : NgRedux<AppState>;
24   let collectionResourceModel: CollectionResourceModelInfo;
25   let  _sharedTreeService : SharedTreeService;
26
27   beforeEach(done => (async () => {
28     TestBed.configureTestingModule({
29       imports: [HttpClientTestingModule, NgReduxTestingModule],
30       providers: [
31         MockNgRedux,
32         DynamicInputsService,
33         SharedTreeService,
34         DuplicateService,
35         AaiService,
36         HttpClient,
37         HttpHandler,
38         FeatureFlagsService,
39         ComponentInfoService,
40         IframeService]
41     });
42     await TestBed.compileComponents();
43     injector = getTestBed();
44     _store = injector.get(NgRedux);
45     _componentInfoService = injector.get(ComponentInfoService);
46     _sharedTreeService = injector.get(SharedTreeService);
47
48     collectionResourceModel = new CollectionResourceModelInfo(_store, _sharedTreeService);
49
50
51   })().then(done).catch(done.fail));
52
53   test('collection resource should be defined', () => {
54     expect(collectionResourceModel).toBeDefined();
55   });
56
57   test('collectionResourceModel should defined extra details', () => {
58     expect(collectionResourceModel.name).toEqual('collectionResources');
59     expect(collectionResourceModel.type).toEqual('collection Resource');
60     expect(collectionResourceModel.childNames).toEqual(['ncfs']);
61     expect(collectionResourceModel.componentInfoType).toEqual(ComponentInfoType.COLLECTION_RESOURCE);
62   });
63
64   test('isEcompGeneratedNaming should return false', () => {
65     let isEcompGeneratedNaming: boolean = collectionResourceModel.isEcompGeneratedNaming(<any>{});
66     expect(isEcompGeneratedNaming).toBeFalsy();
67   });
68
69
70   test('getTooltip should return "Collection Resource"', () => {
71     let tooltip: string = collectionResourceModel.getTooltip();
72     expect(tooltip).toEqual('Collection Resource');
73   });
74
75   test('getType should return "collectionResources"', () => {
76     let tooltip: string = collectionResourceModel.getType();
77     expect(tooltip).toEqual('collectionResource');
78   });
79
80   test('getNextLevelObject should return ncfs', () => {
81     let nextLevel: NcfModelInfo = collectionResourceModel.getNextLevelObject();
82     expect(nextLevel.type).toEqual('NCF');
83   });
84
85   test('getModel should return collectionResource model', () => {
86     expect(collectionResourceModel.getModel({})).toBeInstanceOf(CollectionResourceModel);
87   });
88
89   test('cr getMenuAction: delete', ()=>{
90     let node = {};
91     let serviceModelId = 'serviceModelId';
92     let result = collectionResourceModel.getMenuAction(<any>node, serviceModelId);
93     spyOn(result['delete'], 'method');
94     expect(result['delete']).toBeDefined();
95     expect(result['delete'].visible()).toBeFalsy();
96     expect(result['delete'].enable()).toBeFalsy();
97     result['delete']['method'](node, serviceModelId);
98     expect(result['delete']['method']).toHaveBeenCalledWith(node, serviceModelId);
99   });
100
101 });