@labdigital/commercetools-mock 2.16.0 → 2.16.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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
3
  "author": "Michael van Tellingen",
4
- "version": "2.16.0",
4
+ "version": "2.16.1",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
@@ -345,7 +345,7 @@ export class ShoppingListRepository extends AbstractResourceRepository<'shopping
345
345
  ),
346
346
  }
347
347
 
348
- if (variantId) {
348
+ if (productId && variantId) {
349
349
  return lineItem
350
350
  }
351
351
 
@@ -367,6 +367,7 @@ export class ShoppingListRepository extends AbstractResourceRepository<'shopping
367
367
  ]
368
368
  const variantId = allVariants.find((e) => e.sku === sku)?.id
369
369
  lineItem.variantId = variantId
370
+ lineItem.productId = product.id
370
371
  return lineItem
371
372
  }
372
373
 
@@ -93,7 +93,7 @@ describe('Shopping List', () => {
93
93
  expect(response.body.lineItems[0].variantId).toBe(2)
94
94
  })
95
95
 
96
- test('Expands variant on lineItems', async () => {
96
+ test('Expands variant on lineItems when getting', async () => {
97
97
  const response = await supertest(ctMock.app)
98
98
  .get(`/dummy/shopping-lists/${shoppingList.id}`)
99
99
  .query({ expand: 'lineItems[*].variant' })
@@ -104,6 +104,23 @@ describe('Shopping List', () => {
104
104
  sku: '22241940260',
105
105
  })
106
106
  })
107
+
108
+ test('Expands variant on lineItems when creating', async () => {
109
+ const draft: ShoppingListDraft = {
110
+ name: {},
111
+ lineItems: [{ sku: '22241940260' }],
112
+ }
113
+ const response = await supertest(ctMock.app)
114
+ .post('/dummy/shopping-lists')
115
+ .query({ expand: 'lineItems[*].variant' })
116
+ .send(draft)
117
+
118
+ expect(response.status).toBe(201)
119
+ expect(response.body.lineItems[0].variant).toEqual({
120
+ id: 2,
121
+ sku: '22241940260',
122
+ })
123
+ })
107
124
  })
108
125
 
109
126
  describe('Shopping List Update Actions', () => {