6cb779145e0ac5f6d50e11bafca670f0a10f1940
[clamp.git] / src / test / javascript / propertyController.test.js
1
2 describe('Property controller tests', function() {
3         var clModel = '{"name": "ClosedLoopTest","dcaeDeploymentId":"testId","dcaeDeploymentStatusUrl":"testUrl","lastComputedState":"DESIGN","svgRepresentation": "representation","globalPropertiesJson": [{"name":"deployParameters","value":{"location_id":"","service_id":"","policy_id":"AUTO_GENERATED_POLICY_ID_AT_SUBMIT"}}], "blueprint": "yaml","lastComputedState": "DESIGN","operationalPolicies": [ {"name": "OpPolicyTest", "configurationsJson": { "policy1": [{"name": "pname","value": "policy1"}]}}],"microServicePolicies": [{"name": "tca","properties": "", "shared": true,"policyTosca": "tosca","jsonRepresentation": {"schema":{"title":"DCAE TCA Config","type":"object","required":["name"],"properties":{"name":{"propertyOrder":101,"title":"Name","type":"string"}}}}}],"loopLogs": [{ } ] }';
4         cl_props = JSON.parse(clModel);
5         var propertyController = require('scripts/propertyController.js');
6         
7         test('getOperationalPolicyProperty', () => {
8                 var policyProp = '{"policy1": [{"name": "pname","value": "policy1"}]}';
9                 expect(propertyController.getOperationalPolicyProperty()).toEqual(JSON.parse(policyProp));
10         });
11
12         test('getGlobalProperty', () => {
13                 var globalProp = '[{"name":"deployParameters","value":{"location_id":"","service_id":"","policy_id":"AUTO_GENERATED_POLICY_ID_AT_SUBMIT"}}]';
14                 expect(propertyController.getGlobalProperty()).toEqual(JSON.parse(globalProp));
15         });
16
17         test('getMsPropertyTca', () => {
18                 expect(propertyController.getMsProperty("tca")).toEqual('');
19         });
20
21         test('getMsUITca', () => {
22                 var msUI = '{"schema":{"title":"DCAE TCA Config","type":"object","required":["name"],"properties":{"name":{"propertyOrder":101,"title":"Name","type":"string"}}}}';
23                 expect(propertyController.getMsUI("tca")).toEqual(JSON.parse(msUI));
24         });
25
26         test('getMsPropertyNotExist', () => {
27                   expect(propertyController.getMsProperty("test")).toEqual(null);
28         });
29
30         test('getMsUINotExist', () => {
31                   expect(propertyController.getMsUI("test")).toEqual(null);
32         });
33
34         test('getStatus', () => {
35                   expect(propertyController.getStatus()).toEqual('DESIGN');
36         });
37
38         test('getDeploymentID', () => {
39                   expect(propertyController.getDeploymentID()).toEqual('testId');
40         });
41
42         test('getDeploymentStatusURL', () => {
43                   expect(propertyController.getDeploymentStatusURL()).toEqual('testUrl');
44         });
45 });