1 import {TestBed, getTestBed} from '@angular/core/testing';
3 HttpClientTestingModule,
5 } from '@angular/common/http/testing';
6 import {NgRedux} from "@angular-redux/store";
7 import {DrawingBoardTreeService, TreeNodeContextMenuModel} from "./drawing-board-tree.service";
8 import {ITreeNode} from "angular-tree-component/dist/defs/api";
10 class MockAppStore<T> {
15 "serviceInstanceId": {
46 describe('Drawing board tree Service', () => {
48 let service: DrawingBoardTreeService;
49 let httpMock: HttpTestingController;
52 beforeAll(done => (async () => {
53 TestBed.configureTestingModule({
54 imports: [HttpClientTestingModule],
56 DrawingBoardTreeService,
57 {provide: NgRedux, useClass: MockAppStore}]
59 await TestBed.compileComponents();
61 injector = getTestBed();
62 service = injector.get(DrawingBoardTreeService);
63 httpMock = injector.get(HttpTestingController);
65 })().then(done).catch(done.fail));
68 test('generateContextMenuOptions should return list of optional context menu', () => {
69 const options: TreeNodeContextMenuModel[] = service.generateContextMenuOptions();
70 const expected: TreeNodeContextMenuModel[] = [
71 new TreeNodeContextMenuModel('edit', 'context-menu-edit', 'Edit', 'edit-file-o'),
72 new TreeNodeContextMenuModel('duplicate', 'context-menu-duplicate', 'Duplicate', 'copy-o'),
73 new TreeNodeContextMenuModel('showAuditInfo', 'context-menu-showAuditInfo', 'Show audit info', 'eye-o'),
74 new TreeNodeContextMenuModel('addGroupMember', 'context-menu-addGroupMember', 'Add group members', 'plus'),
75 new TreeNodeContextMenuModel('delete', 'context-menu-delete', 'Delete', 'trash-o'),
76 new TreeNodeContextMenuModel('remove', 'context-menu-remove', 'Remove', 'trash-o'),
77 new TreeNodeContextMenuModel('undoDelete', 'context-menu-undoDelete', 'Undo Delete', 'undo-delete'),
78 new TreeNodeContextMenuModel('changeAssociations', 'context-menu-changeAssociations', 'Change Associations', 'edit-file-o')
80 expect(options.length).toEqual(8);
81 expect(options).toEqual(expected);
84 test('isVNFMissingData should return true if vnf isMissingData = true', () => {
85 let node: ITreeNode = <any>{
88 vnfStoreKey: "vnfStoreKey"
91 let result: boolean = service.isVNFMissingData(node, "serviceInstanceId");
92 expect(result).toBeTruthy();
96 test('isVNFMissingData should return false if vnf has isMissingData = false', () => {
97 let node: ITreeNode = <any>{
100 modelName: "vfModulesName",
101 dynamicModelName: "vfModulesName",
103 vnfStoreKey: "vnfStoreKey1",
108 let result: boolean = service.isVNFMissingData(node, "serviceInstanceId");
109 expect(result).toBeFalsy();
113 test('isVFModuleMissingData should return true if vnfModule has isMissingData = true', () => {
114 let node: ITreeNode = <any>{
117 modelName: "vfModulesName",
118 dynamicModelName: "vfModulesName",
120 vnfStoreKey: "vnfStoreKey",
125 let result: boolean = service.isVFModuleMissingData(node, "serviceInstanceId");
126 expect(result).toBeFalsy();
130 test('isVFModuleMissingData should return false if vnfModule has isMissingData = false', () => {
131 let node: ITreeNode = <any>{
134 modelName: "vfModulesName",
135 dynamicModelName: "vfModulesName",
137 vnfStoreKey: "vnfStoreKey1",
142 let result: boolean = service.isVFModuleMissingData(node, "serviceInstanceId");
143 expect(result).toBeFalsy();