@labdigital/commercetools-mock 2.22.0 → 2.22.1
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 +3 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/cart/actions.ts +9 -0
- package/src/services/cart.test.ts +20 -0
package/package.json
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
type CartAddItemShippingAddressAction,
|
|
9
9
|
type CartAddLineItemAction,
|
|
10
10
|
type CartChangeLineItemQuantityAction,
|
|
11
|
+
type CartChangeTaxRoundingModeAction,
|
|
11
12
|
type CartRemoveDiscountCodeAction,
|
|
12
13
|
type CartRemoveLineItemAction,
|
|
13
14
|
type CartSetBillingAddressAction,
|
|
@@ -229,6 +230,14 @@ export class CartUpdateHandler
|
|
|
229
230
|
resource.totalPrice.centAmount = calculateCartTotalPrice(resource);
|
|
230
231
|
}
|
|
231
232
|
|
|
233
|
+
changeTaxRoundingMode(
|
|
234
|
+
_context: RepositoryContext,
|
|
235
|
+
resource: Writable<Cart>,
|
|
236
|
+
{ taxRoundingMode }: CartChangeTaxRoundingModeAction,
|
|
237
|
+
) {
|
|
238
|
+
resource.taxRoundingMode = taxRoundingMode;
|
|
239
|
+
}
|
|
240
|
+
|
|
232
241
|
recalculate() {
|
|
233
242
|
// Dummy action when triggering a recalculation of the cart
|
|
234
243
|
//
|
|
@@ -303,6 +303,26 @@ describe("Cart Update Actions", () => {
|
|
|
303
303
|
expect(response.body.lineItems).toHaveLength(0);
|
|
304
304
|
});
|
|
305
305
|
|
|
306
|
+
test("changeTaxRoundingMode", async () => {
|
|
307
|
+
assert(cart, "cart not created");
|
|
308
|
+
|
|
309
|
+
const response = await supertest(ctMock.app)
|
|
310
|
+
.post(`/dummy/carts/${cart.id}`)
|
|
311
|
+
.send({
|
|
312
|
+
version: 1,
|
|
313
|
+
actions: [
|
|
314
|
+
{
|
|
315
|
+
action: "changeTaxRoundingMode",
|
|
316
|
+
taxRoundingMode: "HalfUp",
|
|
317
|
+
},
|
|
318
|
+
],
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
expect(response.status).toBe(200);
|
|
322
|
+
expect(response.body.version).toBe(2);
|
|
323
|
+
expect(response.body.taxRoundingMode).toBe("HalfUp");
|
|
324
|
+
});
|
|
325
|
+
|
|
306
326
|
test("recalculate", async () => {
|
|
307
327
|
await supertest(ctMock.app)
|
|
308
328
|
.post(`/dummy/products`)
|