Add new code new version
[sdc.git] / openecomp-ui / test / softwareProduct / networks / softwareProductNetworksActionHelper.test.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 import {expect} from 'chai';
22 import deepFreeze from 'deep-freeze';
23 import mockRest from 'test-utils/MockRest.js';
24 import {cloneAndSet} from 'test-utils/Util.js';
25 import {storeCreator} from 'sdc-app/AppStore.js';
26 import SoftwareProductNetworksActionHelper from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js';
27
28 const softwareProductId = '123';
29
30 describe('Software Product Networks ActionHelper Tests', function () {
31         it('Get Software Products Networks List', () => {
32                 const store = storeCreator();
33                 deepFreeze(store.getState());
34
35                 const networksList = [
36                         {
37                                 name:'dummy_net_1',
38                                 dhcp:true,
39                                 'id':'7F60CD390458421DA588AF4AD217B93F'
40                         },
41                         {
42                                 name:'dummy_net_2',
43                                 dhcp:true,
44                                 'id':'AD217B93F7F60CD390458421DA588AF4'
45                         }
46                 ];
47
48                 deepFreeze(networksList);
49                 const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductNetworks.networksList', networksList);
50
51                 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
52                         expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/networks`);
53                         expect(data).to.deep.equal(undefined);
54                         expect(options).to.equal(undefined);
55                         return {results: networksList};
56                 });
57
58                 return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId}).then(() => {
59                         expect(store.getState()).to.deep.equal(expectedStore);
60                 });
61
62         });
63 });