summaryrefslogtreecommitdiffstats
path: root/vid-webpack-master/src/app/drawingBoard/service-planning/objectsToTree/models/collectionResource/collectionResource.model.info.spec.ts
blob: 2f143fa37551da9987c8849f0093d25828de6fe5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import {HttpClientTestingModule} from "@angular/common/http/testing";
import {getTestBed, TestBed} from "@angular/core/testing";
import {MockNgRedux, NgReduxTestingModule} from "@angular-redux/store/testing";
import {DynamicInputsService} from "../../dynamicInputs.service";
import {SharedTreeService} from "../../shared.tree.service";
import {NgRedux} from "@angular-redux/store";
import {AppState} from "../../../../../shared/store/reducers";
import {DuplicateService} from "../../../duplicate/duplicate.service";
import {IframeService} from "../../../../../shared/utils/iframe.service";
import {ComponentInfoService} from "../../../component-info/component-info.service";
import {AaiService} from "../../../../../shared/services/aaiService/aai.service";
import {HttpClient, HttpHandler} from "@angular/common/http";
import {FeatureFlagsService} from "../../../../../shared/services/featureFlag/feature-flags.service";
import {CollectionResourceModelInfo} from "./collectionResource.model.info";
import {ComponentInfoType} from "../../../component-info/component-info-model";
import {CollectionResourceModel} from "../../../../../shared/models/collectionResourceModel";
import {NcfModelInfo} from "../ncf/ncf.model.info";

describe('Collection Resource Model Info', () => {
  let injector;
  let _componentInfoService : ComponentInfoService;

  let _store : NgRedux<AppState>;
  let collectionResourceModel: CollectionResourceModelInfo;
  let  _sharedTreeService : SharedTreeService;

  beforeEach(done => (async () => {
    TestBed.configureTestingModule({
      imports: [HttpClientTestingModule, NgReduxTestingModule],
      providers: [
        MockNgRedux,
        DynamicInputsService,
        SharedTreeService,
        DuplicateService,
        AaiService,
        HttpClient,
        HttpHandler,
        FeatureFlagsService,
        ComponentInfoService,
        IframeService]
    });
    await TestBed.compileComponents();
    injector = getTestBed();
    _store = injector.get(NgRedux);
    _componentInfoService = injector.get(ComponentInfoService);
    _sharedTreeService = injector.get(SharedTreeService);

    collectionResourceModel = new CollectionResourceModelInfo(_store, _sharedTreeService);


  })().then(done).catch(done.fail));

  test('collection resource should be defined', () => {
    expect(collectionResourceModel).toBeDefined();
  });

  test('collectionResourceModel should defined extra details', () => {
    expect(collectionResourceModel.name).toEqual('collectionResources');
    expect(collectionResourceModel.type).toEqual('collection Resource');
    expect(collectionResourceModel.childNames).toEqual(['ncfs']);
    expect(collectionResourceModel.componentInfoType).toEqual(ComponentInfoType.COLLECTION_RESOURCE);
  });

  test('isEcompGeneratedNaming should return false', () => {
    let isEcompGeneratedNaming: boolean = collectionResourceModel.isEcompGeneratedNaming(<any>{});
    expect(isEcompGeneratedNaming).toBeFalsy();
  });


  test('getTooltip should return "Collection Resource"', () => {
    let tooltip: string = collectionResourceModel.getTooltip();
    expect(tooltip).toEqual('Collection Resource');
  });

  test('getType should return "collectionResources"', () => {
    let tooltip: string = collectionResourceModel.getType();
    expect(tooltip).toEqual('collectionResource');
  });

  test('getNextLevelObject should return ncfs', () => {
    let nextLevel: NcfModelInfo = collectionResourceModel.getNextLevelObject();
    expect(nextLevel.type).toEqual('NCF');
  });

  test('getModel should return collectionResource model', () => {
    expect(collectionResourceModel.getModel({})).toBeInstanceOf(CollectionResourceModel);
  });

  test('cr getMenuAction: delete', ()=>{
    let node = {};
    let serviceModelId = 'serviceModelId';
    let result = collectionResourceModel.getMenuAction(<any>node, serviceModelId);
    spyOn(result['delete'], 'method');
    expect(result['delete']).toBeDefined();
    expect(result['delete'].visible()).toBeFalsy();
    expect(result['delete'].enable()).toBeFalsy();
    result['delete']['method'](node, serviceModelId);
    expect(result['delete']['method']).toHaveBeenCalledWith(node, serviceModelId);
  });

});