2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 import expect from 'expect';
22 import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js';
23 import {storeCreator} from 'sdc-app/AppStore.js';
24 import deepFreeze from 'deep-freeze';
25 import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
32 describe('SoftwareProductAttachments ActionHelper', () => {
34 it('function does exist', () => {
35 expect(SoftwareProductAttachmentsActionHelper).toExist();
38 it('toggleExpanded function check', () => {
41 const validationData = {
45 fileName: 'hot-mog-0108-bs1271.yml',
47 fileName: 'hot-mog-0108-bs1271.env'
52 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]'
56 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]'
64 const currentSoftwareProduct = {
68 vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
69 category: 'resourceNewCategory.application l4+',
70 subCategory: 'resourceNewCategory.application l4+.database',
71 id: 'D4774719D085414E9D5642D1ACD59D20',
73 viewableVersions: ['0.1', '0.2'],
75 lockingUser: 'cs0008',
80 const store = storeCreator();
81 deepFreeze(store.getState());
82 deepFreeze(currentSoftwareProduct);
85 type:actionTypes.SOFTWARE_PRODUCT_LOADED,
86 response: currentSoftwareProduct
89 expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(true);
90 SoftwareProductAttachmentsActionHelper.toggleExpanded(store.dispatch, {path:[0]});
91 expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(false);
94 it('onSelectNode & onUnselectNode function check', () => {
97 const validationData = {
101 fileName: 'hot-mog-0108-bs1271.yml',
103 fileName: 'hot-mog-0108-bs1271.env'
108 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]'
112 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]'
120 const currentSoftwareProduct = {
124 vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
125 category: 'resourceNewCategory.application l4+',
126 subCategory: 'resourceNewCategory.application l4+.database',
127 id: 'D4774719D085414E9D5642D1ACD59D20',
129 viewableVersions: ['0.1', '0.2'],
131 lockingUser: 'cs0008',
135 deepFreeze(currentSoftwareProduct);
137 const store = storeCreator();
138 deepFreeze(store.getState());
141 type:actionTypes.SOFTWARE_PRODUCT_LOADED,
142 response: currentSoftwareProduct
144 let expectedNodeName = 'name';
145 expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
146 SoftwareProductAttachmentsActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName});
147 expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(expectedNodeName);
148 SoftwareProductAttachmentsActionHelper.onUnselectNode(store.dispatch);
149 expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);