@labdigital/commercetools-mock 1.6.1 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +61 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +61 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/cart-discount.ts +49 -1
- package/src/repositories/category.ts +49 -0
- package/src/repositories/store.ts +8 -0
- package/src/services/cart-discount.test.ts +362 -0
- package/src/services/category.test.ts +117 -2
package/dist/index.cjs
CHANGED
|
@@ -2195,7 +2195,12 @@ var CartDiscountRepository = class extends AbstractResourceRepository {
|
|
|
2195
2195
|
stackingMode: draft.stackingMode || "Stacking",
|
|
2196
2196
|
validFrom: draft.validFrom,
|
|
2197
2197
|
validUntil: draft.validUntil,
|
|
2198
|
-
value: this.transformValueDraft(draft.value)
|
|
2198
|
+
value: this.transformValueDraft(draft.value),
|
|
2199
|
+
custom: createCustomFields(
|
|
2200
|
+
draft.custom,
|
|
2201
|
+
context.projectKey,
|
|
2202
|
+
this._storage
|
|
2203
|
+
)
|
|
2199
2204
|
};
|
|
2200
2205
|
this.saveNew(context, resource);
|
|
2201
2206
|
return resource;
|
|
@@ -2249,6 +2254,29 @@ var CartDiscountRepository = class extends AbstractResourceRepository {
|
|
|
2249
2254
|
},
|
|
2250
2255
|
changeIsActive: (context, resource, { isActive }) => {
|
|
2251
2256
|
resource.isActive = isActive;
|
|
2257
|
+
},
|
|
2258
|
+
changeTarget: (context, resource, { target }) => {
|
|
2259
|
+
resource.target = target;
|
|
2260
|
+
},
|
|
2261
|
+
setCustomField: (context, resource, { name, value }) => {
|
|
2262
|
+
if (!resource.custom) {
|
|
2263
|
+
return;
|
|
2264
|
+
}
|
|
2265
|
+
if (value === null) {
|
|
2266
|
+
if (name in resource.custom.fields) {
|
|
2267
|
+
delete resource.custom.fields[name];
|
|
2268
|
+
} else {
|
|
2269
|
+
throw new CommercetoolsError(
|
|
2270
|
+
{
|
|
2271
|
+
code: "InvalidOperation",
|
|
2272
|
+
message: "Cannot remove custom field " + name + " because it does not exist."
|
|
2273
|
+
},
|
|
2274
|
+
400
|
|
2275
|
+
);
|
|
2276
|
+
}
|
|
2277
|
+
} else {
|
|
2278
|
+
resource.custom.fields[name] = value;
|
|
2279
|
+
}
|
|
2252
2280
|
}
|
|
2253
2281
|
};
|
|
2254
2282
|
};
|
|
@@ -2259,6 +2287,11 @@ var CategoryRepository = class extends AbstractResourceRepository {
|
|
|
2259
2287
|
getTypeId() {
|
|
2260
2288
|
return "category";
|
|
2261
2289
|
}
|
|
2290
|
+
assetFromAssetDraft = (draft, context) => ({
|
|
2291
|
+
...draft,
|
|
2292
|
+
id: (0, import_uuid4.v4)(),
|
|
2293
|
+
custom: createCustomFields(draft.custom, context.projectKey, this._storage)
|
|
2294
|
+
});
|
|
2262
2295
|
create(context, draft) {
|
|
2263
2296
|
const resource = {
|
|
2264
2297
|
...getBaseResourceProperties(),
|
|
@@ -2361,6 +2394,30 @@ var CategoryRepository = class extends AbstractResourceRepository {
|
|
|
2361
2394
|
} else {
|
|
2362
2395
|
resource.custom.fields[name] = value;
|
|
2363
2396
|
}
|
|
2397
|
+
},
|
|
2398
|
+
removeAsset: (context, resource, { assetId, assetKey }) => {
|
|
2399
|
+
if (!resource.assets) {
|
|
2400
|
+
return;
|
|
2401
|
+
}
|
|
2402
|
+
if (assetId) {
|
|
2403
|
+
resource.assets = resource.assets.filter(function(obj) {
|
|
2404
|
+
return obj.id !== assetId;
|
|
2405
|
+
});
|
|
2406
|
+
return;
|
|
2407
|
+
}
|
|
2408
|
+
if (assetKey) {
|
|
2409
|
+
resource.assets = resource.assets.filter(function(obj) {
|
|
2410
|
+
return obj.key !== assetKey;
|
|
2411
|
+
});
|
|
2412
|
+
return;
|
|
2413
|
+
}
|
|
2414
|
+
},
|
|
2415
|
+
addAsset: (context, resource, { asset }) => {
|
|
2416
|
+
if (!resource.assets) {
|
|
2417
|
+
resource.assets = [this.assetFromAssetDraft(asset, context)];
|
|
2418
|
+
} else {
|
|
2419
|
+
resource.assets.push(this.assetFromAssetDraft(asset, context));
|
|
2420
|
+
}
|
|
2364
2421
|
}
|
|
2365
2422
|
};
|
|
2366
2423
|
};
|
|
@@ -4919,6 +4976,9 @@ var StoreRepository = class extends AbstractResourceRepository {
|
|
|
4919
4976
|
} else {
|
|
4920
4977
|
resource.custom.fields[name] = value;
|
|
4921
4978
|
}
|
|
4979
|
+
},
|
|
4980
|
+
setCountries: (context, resource, { countries }) => {
|
|
4981
|
+
resource.countries = countries ?? [];
|
|
4922
4982
|
}
|
|
4923
4983
|
};
|
|
4924
4984
|
};
|