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 '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';
28 const softwareProductId = '123';
30 describe('Software Product Networks ActionHelper Tests', function () {
31 it('Get Software Products Networks List', () => {
32 const store = storeCreator();
33 deepFreeze(store.getState());
35 const networksList = [
39 'id':'7F60CD390458421DA588AF4AD217B93F'
44 'id':'AD217B93F7F60CD390458421DA588AF4'
48 deepFreeze(networksList);
49 const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductNetworks.networksList', networksList);
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};
58 return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId}).then(() => {
59 expect(store.getState()).to.deep.equal(expectedStore);