@labdigital/commercetools-mock 2.30.1 → 2.31.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.
@@ -259,6 +259,67 @@ describe("Cart Update Actions", () => {
259
259
  expect(response.body.totalPrice.centAmount).toEqual(total);
260
260
  });
261
261
 
262
+ test("addLineItem with custom field", async () => {
263
+ const product = await supertest(ctMock.app)
264
+ .post(`/dummy/products`)
265
+ .send(productDraft)
266
+ .then((x) => x.body);
267
+
268
+ const type = await supertest(ctMock.app)
269
+ .post(`/dummy/types`)
270
+ .send({
271
+ key: "my-type",
272
+ name: {
273
+ en: "My Type",
274
+ },
275
+ description: {
276
+ en: "My Type Description",
277
+ },
278
+ fieldDefinitions: [
279
+ {
280
+ name: "foo",
281
+ label: {
282
+ en: "foo",
283
+ },
284
+ required: false,
285
+ type: {
286
+ name: "String",
287
+ },
288
+ inputHint: "SingleLine",
289
+ },
290
+ ],
291
+ })
292
+ .then((x) => x.body);
293
+
294
+ assert(type, "type not created");
295
+ assert(cart, "cart not created");
296
+ assert(product, "product not created");
297
+
298
+ const response = await supertest(ctMock.app)
299
+ .post(`/dummy/carts/${cart.id}`)
300
+ .send({
301
+ version: 1,
302
+ actions: [
303
+ {
304
+ action: "addLineItem",
305
+ sku: "1337",
306
+ quantity: 2,
307
+ custom: {
308
+ type: { typeId: "type", key: "my-type" },
309
+ fields: { foo: "bar" },
310
+ },
311
+ },
312
+ ],
313
+ });
314
+ expect(response.status).toBe(200);
315
+ expect(response.body.version).toBe(2);
316
+ expect(response.body.lineItems).toHaveLength(1);
317
+ expect(response.body.lineItems[0].custom).toEqual({
318
+ type: { typeId: "type", id: expect.any(String) },
319
+ fields: { foo: "bar" },
320
+ });
321
+ });
322
+
262
323
  test("addLineItem unknown product", async () => {
263
324
  assert(cart, "cart not created");
264
325