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
102
103
104
105
106
107
108
109
110
111
112
|
import {ComponentInfoType} from "../../../component-info/component-info-model";
import {NcfModelInfo} from "./ncf.model.info";
import {ModelInformationItem} from "../../../../../shared/components/model-information/model-information.component";
import {NcfTreeNode} from "../../../../../shared/models/ncfTreeNode";
describe('NCF Model Info', () => {
let ncfModel: NcfModelInfo;
beforeEach(() => {
ncfModel = new NcfModelInfo(null);
});
test('ncfModel should be defined', () => {
expect(ncfModel).toBeDefined();
});
test('ncfModel should defined extra details', () => {
expect(ncfModel.name).toEqual('ncfs');
expect(ncfModel.type).toEqual('NCF');
expect(ncfModel.childNames).toBeUndefined;
expect(ncfModel.componentInfoType).toEqual(ComponentInfoType.NCF);
});
test('createInstanceTreeNode shall create the right ncfTreeNode', () => {
const instance = {
action: "None",
instanceName: "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
instanceId: "6b3536cf-3a12-457f-abb5-fa2203e0d923",
instanceType: "L3-NETWORK",
inMaint: false,
uuid: "dd182d7d-6949-4b90-b3cc-5befe400742e",
originalName: "ncm_vlan_ym161f..NetworkCollection..0",
trackById: "6b3536cf-3a12-457f-abb5-fa2203e0d923",
instanceGroupRole: "SUB_INTERFACE",
instanceGroupFunction: "vTSBC Customer Landing Network Collection",
numberOfNetworks: 1
};
const parentModel = {
networksCollection: {
"ncm_vlan_ym161f..NetworkCollection..0": {
uuid: "dd182d7d-6949-4b90-b3cc-5befe400742e",
invariantUuid: "868b109c-9481-4a18-891b-af974db7705a",
name: "ncm_vlan_ym161f..NetworkCollection..0",
version: "1",
networkCollectionProperties: {
networkCollectionFunction: "vTSBC Customer Landing Network Collection",
networkCollectionDescription: "vTSBC Customer Landing Network Collection Desc"
}
}
}
};
const expected = {
action: "None",
id: "6b3536cf-3a12-457f-abb5-fa2203e0d923",
inMaint: false,
instanceGroupFunction: "vTSBC Customer Landing Network Collection",
instanceGroupRole: "SUB_INTERFACE",
instanceId: "6b3536cf-3a12-457f-abb5-fa2203e0d923",
instanceName: "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
instanceType: "L3-NETWORK",
missingData: false,
modelVersion: "1",
name: "NcmVlanSvcYm161f_77_vTSBC Customer Landing Network Collection",
numberOfNetworks: 1,
storeKey: "6b3536cf-3a12-457f-abb5-fa2203e0d923",
typeName: "NCF"
};
const ncfTreeNode: NcfTreeNode = ncfModel.createInstanceTreeNode(instance, {}, parentModel, "6b3536cf-3a12-457f-abb5-fa2203e0d923");
expect(ncfTreeNode).toMatchObject(expected);
});
test('get modelInformation shall return Model version, role, Collection function, Number of networks', () => {
const ncf = {
trackById: "6b3536cf-3a12-457f-abb5-fa2203e0d923",
instanceGroupRole: "SUB_INTERFACE",
instanceGroupFunction: "vTSBC Customer Landing Network Collection",
numberOfNetworks: 1,
modelVersion: "35"
};
const actualModelInformationItems = ncfModel.getInfo(null, ncf);
const expected = [
ModelInformationItem.createInstance('Model version', '35'),
ModelInformationItem.createInstance('Role', 'SUB_INTERFACE'),
ModelInformationItem.createInstance('Collection function', 'vTSBC Customer Landing Network Collection'),
ModelInformationItem.createInstance('Number of networks', 1),
];
expect(actualModelInformationItems).toEqual(expected);
});
test('get modelInformation shall return empty array when ncf instance is null', () => {
expect(ncfModel.getInfo(null, null)).toEqual([]);
});
test('ncf getMenuAction: delete', ()=>{
let node = {};
let serviceModelId = 'serviceModelId';
let result = ncfModel.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);
});
});
|