AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 3 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and limitations under the License. |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 15 | */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 16 | import deepFreeze from 'deep-freeze'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 17 | import mockRest from 'test-utils/MockRest.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 18 | import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 19 | import {storeCreator} from 'sdc-app/AppStore.js'; |
| 20 | import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 21 | import {EntitlementPoolStoreFactory, EntitlementPoolPostFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js'; |
| 22 | import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 23 | import {LimitItemFactory, LimitPostFactory} from 'test-utils/factories/licenseModel/LimitFactories.js'; |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 24 | import {getStrValue} from 'nfvo-utils/getValue.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 25 | |
| 26 | describe('Entitlement Pools Module Tests', function () { |
| 27 | |
| 28 | const LICENSE_MODEL_ID = '555'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 29 | const version = VersionControllerUtilsFactory.build().version; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 30 | |
| 31 | it('Load Entitlement Pools List', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 32 | |
| 33 | const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 34 | deepFreeze(entitlementPoolsList); |
| 35 | const store = storeCreator(); |
| 36 | deepFreeze(store.getState()); |
| 37 | |
| 38 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', entitlementPoolsList); |
| 39 | |
| 40 | mockRest.addHandler('fetch', ({data, options, baseUrl}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 41 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`); |
| 42 | expect(data).toEqual(undefined); |
| 43 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 44 | return {results: entitlementPoolsList}; |
| 45 | }); |
| 46 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 47 | return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => { |
| 48 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 49 | }); |
| 50 | }); |
| 51 | |
| 52 | it('Delete Entitlement Pool', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 53 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 54 | const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory,1); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 55 | deepFreeze(entitlementPoolsList); |
| 56 | const store = storeCreator({ |
| 57 | licenseModel: { |
| 58 | entitlementPool: { |
| 59 | entitlementPoolsList |
| 60 | } |
| 61 | } |
| 62 | }); |
| 63 | deepFreeze(store.getState()); |
| 64 | |
| 65 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []); |
| 66 | |
| 67 | mockRest.addHandler('destroy', ({data, options, baseUrl}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 68 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPoolsList[0].id}`); |
| 69 | expect(data).toEqual(undefined); |
| 70 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 71 | return { |
| 72 | results: { |
| 73 | returnCode: 'OK' |
| 74 | } |
| 75 | }; |
| 76 | }); |
| 77 | |
| 78 | return EntitlementPoolsActionHelper.deleteEntitlementPool(store.dispatch, { |
| 79 | licenseModelId: LICENSE_MODEL_ID, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 80 | version, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 81 | entitlementPoolId: entitlementPoolsList[0].id |
| 82 | }).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 83 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 84 | }); |
| 85 | }); |
| 86 | |
| 87 | it('Add Entitlement Pool', () => { |
| 88 | |
| 89 | const store = storeCreator(); |
| 90 | deepFreeze(store.getState()); |
| 91 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 92 | const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build(); |
| 93 | |
| 94 | deepFreeze(EntitlementPoolPostRequest); |
| 95 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 96 | const entitlementPoolIdFromResponse = 'ADDED_ID'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 97 | const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({id: entitlementPoolIdFromResponse}); |
| 98 | deepFreeze(entitlementPoolAfterAdd); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 99 | |
| 100 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]); |
| 101 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 102 | mockRest.addHandler('post', ({data, options, baseUrl}) => { |
| 103 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`); |
| 104 | expect(data).toEqual(EntitlementPoolPostRequest); |
| 105 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 106 | return { |
| 107 | returnCode: 'OK', |
| 108 | value: entitlementPoolIdFromResponse |
| 109 | }; |
| 110 | }); |
| 111 | |
| 112 | return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, |
| 113 | { |
| 114 | licenseModelId: LICENSE_MODEL_ID, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 115 | version, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 116 | previousEntitlementPool: null, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 117 | entitlementPool: EntitlementPoolPostRequest |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 118 | } |
| 119 | ).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 120 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 121 | }); |
| 122 | }); |
| 123 | |
| 124 | it('Update Entitlement Pool', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 125 | |
| 126 | const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory, 1); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 127 | deepFreeze(entitlementPoolsList); |
| 128 | |
| 129 | const store = storeCreator({ |
| 130 | licenseModel: { |
| 131 | entitlementPool: { |
| 132 | entitlementPoolsList |
| 133 | } |
| 134 | } |
| 135 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 136 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 137 | deepFreeze(store.getState()); |
| 138 | |
| 139 | const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id; |
| 140 | const previousEntitlementPoolData = entitlementPoolsList[0]; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 141 | const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED', id: toBeUpdatedEntitlementPoolId}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 142 | deepFreeze(entitlementPoolUpdateData); |
| 143 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 144 | const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED'}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 145 | deepFreeze(entitlementPoolPutRequest); |
| 146 | |
| 147 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]); |
| 148 | |
| 149 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 150 | mockRest.addHandler('put', ({data, options, baseUrl}) => { |
| 151 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`); |
| 152 | expect(data).toEqual(entitlementPoolPutRequest); |
| 153 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 154 | return {returnCode: 'OK'}; |
| 155 | }); |
| 156 | |
| 157 | return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, { |
| 158 | licenseModelId: LICENSE_MODEL_ID, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 159 | version, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 160 | previousEntitlementPool: previousEntitlementPoolData, |
| 161 | entitlementPool: entitlementPoolUpdateData |
| 162 | }).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 163 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 164 | }); |
| 165 | }); |
| 166 | |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 167 | it('Load Limits List', () => { |
| 168 | |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 169 | const limitsList = LimitItemFactory.buildList(3); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 170 | deepFreeze(limitsList); |
| 171 | const store = storeCreator(); |
| 172 | deepFreeze(store.getState()); |
| 173 | |
| 174 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', limitsList); |
| 175 | const entitlementPool = EntitlementPoolStoreFactory.build(); |
| 176 | mockRest.addHandler('fetch', ({data, options, baseUrl}) => { |
| 177 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`); |
| 178 | expect(data).toEqual(undefined); |
| 179 | expect(options).toEqual(undefined); |
| 180 | return {results: limitsList}; |
| 181 | }); |
| 182 | |
| 183 | return EntitlementPoolsActionHelper.fetchLimits(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version, entitlementPool}).then(() => { |
| 184 | expect(store.getState()).toEqual(expectedStore); |
| 185 | }); |
| 186 | }); |
| 187 | |
| 188 | it('Add Limit', () => { |
| 189 | |
| 190 | const store = storeCreator(); |
| 191 | deepFreeze(store.getState()); |
| 192 | |
| 193 | const limitToAdd = LimitPostFactory.build(); |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 194 | let limitFromBE = {...limitToAdd}; |
| 195 | limitFromBE.metric = getStrValue(limitFromBE.metric); |
| 196 | limitFromBE.unit = getStrValue(limitFromBE.unit); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 197 | |
| 198 | deepFreeze(limitToAdd); |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 199 | deepFreeze(limitFromBE); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 200 | |
| 201 | const LimitIdFromResponse = 'ADDED_ID'; |
| 202 | const limitAddedItem = {...limitToAdd, id: LimitIdFromResponse}; |
| 203 | deepFreeze(limitAddedItem); |
| 204 | const entitlementPool = EntitlementPoolStoreFactory.build(); |
| 205 | |
| 206 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [limitAddedItem]); |
| 207 | |
| 208 | mockRest.addHandler('post', ({data, options, baseUrl}) => { |
| 209 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`); |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 210 | expect(data).toEqual(limitFromBE); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 211 | expect(options).toEqual(undefined); |
| 212 | return { |
| 213 | returnCode: 'OK', |
| 214 | value: LimitIdFromResponse |
| 215 | }; |
| 216 | }); |
| 217 | |
| 218 | mockRest.addHandler('fetch', ({data, options, baseUrl}) => { |
| 219 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`); |
| 220 | expect(data).toEqual(undefined); |
| 221 | expect(options).toEqual(undefined); |
| 222 | return {results: [limitAddedItem]}; |
| 223 | }); |
| 224 | |
| 225 | return EntitlementPoolsActionHelper.submitLimit(store.dispatch, |
| 226 | { |
| 227 | licenseModelId: LICENSE_MODEL_ID, |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 228 | version, |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 229 | entitlementPool, |
| 230 | limit: limitToAdd |
| 231 | } |
| 232 | ).then(() => { |
| 233 | expect(store.getState()).toEqual(expectedStore); |
| 234 | }); |
| 235 | }); |
| 236 | |
| 237 | |
| 238 | it('Delete Limit', () => { |
| 239 | |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 240 | const limitsList = LimitItemFactory.buildList(1); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 241 | deepFreeze(limitsList); |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 242 | |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 243 | const store = storeCreator({ |
| 244 | licenseModel: { |
| 245 | entitlementPool: { |
| 246 | entitlementPoolEditor: { |
| 247 | limitsList |
| 248 | } |
| 249 | } |
| 250 | } |
| 251 | }); |
| 252 | deepFreeze(store.getState()); |
| 253 | |
| 254 | const entitlementPool = EntitlementPoolStoreFactory.build(); |
| 255 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', []); |
| 256 | |
| 257 | mockRest.addHandler('destroy', ({data, options, baseUrl}) => { |
| 258 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits/${limitsList[0].id}`); |
| 259 | expect(data).toEqual(undefined); |
| 260 | expect(options).toEqual(undefined); |
| 261 | return { |
| 262 | results: { |
| 263 | returnCode: 'OK' |
| 264 | } |
| 265 | }; |
| 266 | }); |
| 267 | |
| 268 | mockRest.addHandler('fetch', ({data, options, baseUrl}) => { |
| 269 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`); |
| 270 | expect(data).toEqual(undefined); |
| 271 | expect(options).toEqual(undefined); |
| 272 | return {results: []}; |
| 273 | }); |
| 274 | |
| 275 | return EntitlementPoolsActionHelper.deleteLimit(store.dispatch, { |
| 276 | licenseModelId: LICENSE_MODEL_ID, |
| 277 | version, |
| 278 | entitlementPool, |
| 279 | limit: limitsList[0] |
| 280 | }).then(() => { |
| 281 | expect(store.getState()).toEqual(expectedStore); |
| 282 | }); |
| 283 | }); |
| 284 | |
| 285 | it('Update Limit', () => { |
| 286 | |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 287 | const limitsList = LimitItemFactory.buildList(1); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 288 | deepFreeze(limitsList); |
| 289 | const entitlementPool = EntitlementPoolStoreFactory.build(); |
| 290 | const store = storeCreator({ |
| 291 | licenseModel: { |
| 292 | entitlementPool: { |
| 293 | entitlementPoolEditor: { |
| 294 | limitsList |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 | }); |
| 299 | |
| 300 | deepFreeze(store.getState()); |
| 301 | |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 302 | |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 303 | const previousData = limitsList[0]; |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 304 | |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 305 | deepFreeze(previousData); |
| 306 | const limitId = limitsList[0].id; |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 307 | |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 308 | let updatedLimit = {...previousData, name: 'updatedLimit'}; |
| 309 | |
| 310 | const updatedLimitForPut = {...updatedLimit, id: undefined}; |
| 311 | updatedLimit.metric = {choice: updatedLimit.metric, other: ''}; |
| 312 | updatedLimit.unit = {choice: updatedLimit.unit, other: ''}; |
| 313 | deepFreeze(updatedLimit); |
| 314 | |
| 315 | const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [updatedLimitForPut]); |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 316 | |
| 317 | |
| 318 | mockRest.addHandler('put', ({data, options, baseUrl}) => { |
| 319 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits/${limitId}`); |
| 320 | expect(data).toEqual(updatedLimitForPut); |
| 321 | expect(options).toEqual(undefined); |
| 322 | return {returnCode: 'OK'}; |
| 323 | }); |
| 324 | |
| 325 | mockRest.addHandler('fetch', ({data, options, baseUrl}) => { |
| 326 | expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`); |
| 327 | expect(data).toEqual(undefined); |
| 328 | expect(options).toEqual(undefined); |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 329 | return {results: [updatedLimitForPut]}; |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 330 | }); |
| 331 | |
| 332 | return EntitlementPoolsActionHelper.submitLimit(store.dispatch, |
| 333 | { |
| 334 | licenseModelId: LICENSE_MODEL_ID, |
az2497 | 644017c | 2017-08-10 17:49:40 +0300 | [diff] [blame] | 335 | version, |
Avi Ziv | 61070c9 | 2017-07-26 17:37:57 +0300 | [diff] [blame] | 336 | entitlementPool, |
| 337 | limit: updatedLimit |
| 338 | } |
| 339 | ).then(() => { |
| 340 | expect(store.getState()).toEqual(expectedStore); |
| 341 | }); |
| 342 | }); |
| 343 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 344 | }); |