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 LicenseModelCreationActionHelper from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js';
28 describe('License Model Module Tests', function () {
29 it('Add License Model', () => {
30 const store = storeCreator();
31 deepFreeze(store.getState());
33 const licenseModelPostRequest = deepFreeze({
35 description: 'string',
39 const licenseModelToAdd = deepFreeze({
40 ...licenseModelPostRequest
43 const licenseModelIdFromResponse = 'ADDED_ID';
44 const licenseModelAfterAdd = deepFreeze({
46 id: licenseModelIdFromResponse
49 const expectedStore = cloneAndSet(store.getState(), 'licenseModelList', [licenseModelAfterAdd]);
51 mockRest.addHandler('create', ({options, data, baseUrl}) => {
52 expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-license-models/');
53 expect(data).to.deep.equal(licenseModelPostRequest);
54 expect(options).to.equal(undefined);
56 value: licenseModelIdFromResponse
60 return LicenseModelCreationActionHelper.createLicenseModel(store.dispatch, {
61 licenseModel: licenseModelToAdd
63 expect(store.getState()).to.deep.equal(expectedStore);