summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/licenseModel/entitlementPools/test.js
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/licenseModel/entitlementPools/test.js')
-rw-r--r--openecomp-ui/test/licenseModel/entitlementPools/test.js177
1 files changed, 49 insertions, 128 deletions
diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js
index 32705385b4..15e1deecd6 100644
--- a/openecomp-ui/test/licenseModel/entitlementPools/test.js
+++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js
@@ -1,52 +1,34 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
import deepFreeze from 'deep-freeze';
-import {expect} from 'chai';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
+import {EntitlementPoolStoreFactory, EntitlementPoolPostFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
describe('Entitlement Pools Module Tests', function () {
const LICENSE_MODEL_ID = '555';
+ const version = VersionControllerUtilsFactory.build().version;
it('Load Entitlement Pools List', () => {
- const entitlementPoolsList = [
- {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- sku: 'DEF2-385A-4521-AAAA',
- id: '1',
- referencingFeatureGroups: [],
- partNumber: '51529'
- }
- ];
+
+ const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory);
deepFreeze(entitlementPoolsList);
const store = storeCreator();
deepFreeze(store.getState());
@@ -54,36 +36,20 @@ describe('Entitlement Pools Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', entitlementPoolsList);
mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: entitlementPoolsList};
});
- return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Delete Entitlement Pool', () => {
- const entitlementPoolsList = [
- {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- sku: 'DEF2-385A-4521-AAAA',
- id: '1',
- referencingFeatureGroups: [],
- partNumber: '51529'
- }
- ];
+ const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory,1);
deepFreeze(entitlementPoolsList);
const store = storeCreator({
licenseModel: {
@@ -97,9 +63,9 @@ describe('Entitlement Pools Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${entitlementPoolsList[0].id}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPoolsList[0].id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {
results: {
returnCode: 'OK'
@@ -109,9 +75,10 @@ describe('Entitlement Pools Module Tests', function () {
return EntitlementPoolsActionHelper.deleteEntitlementPool(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
entitlementPoolId: entitlementPoolsList[0].id
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -120,43 +87,20 @@ describe('Entitlement Pools Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const entitlementPoolPostRequest = {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA',
- };
- const entitlementPoolToAdd = {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA',
- referencingFeatureGroups: []
- };
+ const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build();
+
+ deepFreeze(EntitlementPoolPostRequest);
+
const entitlementPoolIdFromResponse = 'ADDED_ID';
- const entitlementPoolAfterAdd = {
- ...entitlementPoolToAdd,
- id: entitlementPoolIdFromResponse
- };
+ const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({id: entitlementPoolIdFromResponse});
+ deepFreeze(entitlementPoolAfterAdd);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]);
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`);
- expect(data).to.deep.equal(entitlementPoolPostRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(EntitlementPoolPostRequest);
+ expect(options).toEqual(undefined);
return {
returnCode: 'OK',
value: entitlementPoolIdFromResponse
@@ -166,28 +110,18 @@ describe('Entitlement Pools Module Tests', function () {
return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch,
{
licenseModelId: LICENSE_MODEL_ID,
+ version,
previousEntitlementPool: null,
- entitlementPool: entitlementPoolToAdd
+ entitlementPool: EntitlementPoolPostRequest
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Update Entitlement Pool', () => {
- const entitlementPoolsList = [{
- name: 'ep1',
- id: '0',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA'
- }];
+
+ const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory, 1);
deepFreeze(entitlementPoolsList);
const store = storeCreator({
@@ -197,47 +131,34 @@ describe('Entitlement Pools Module Tests', function () {
}
}
});
+
deepFreeze(store.getState());
const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id;
const previousEntitlementPoolData = entitlementPoolsList[0];
- const entitlementPoolUpdateData = {
- ...entitlementPoolsList[0],
- name: 'ep1_UPDATED',
- description: 'string_UPDATED'
- };
+ const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED', id: toBeUpdatedEntitlementPoolId});
deepFreeze(entitlementPoolUpdateData);
- const entitlementPoolPutRequest = {
- name: 'ep1_UPDATED',
- description: 'string_UPDATED',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA'
- };
+ const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED'});
deepFreeze(entitlementPoolPutRequest);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`);
- expect(data).to.deep.equal(entitlementPoolPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`);
+ expect(data).toEqual(entitlementPoolPutRequest);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
previousEntitlementPool: previousEntitlementPoolData,
entitlementPool: entitlementPoolUpdateData
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});