@labdigital/commercetools-mock 2.18.2 → 2.20.0

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@labdigital/commercetools-mock",
3
- "version": "2.18.2",
3
+ "version": "2.20.0",
4
4
  "license": "MIT",
5
5
  "author": "Michael van Tellingen",
6
6
  "type": "module",
@@ -7,7 +7,9 @@ import type {
7
7
  CustomerSetCustomFieldAction,
8
8
  CustomerSetCustomerNumberAction,
9
9
  CustomerSetFirstNameAction,
10
+ CustomerSetKeyAction,
10
11
  CustomerSetLastNameAction,
12
+ CustomerSetSalutationAction,
11
13
  CustomerSetVatIdAction,
12
14
  CustomerUpdateAction,
13
15
  InvalidInputError,
@@ -147,6 +149,14 @@ export class CustomerUpdateHandler
147
149
  resource.firstName = firstName;
148
150
  }
149
151
 
152
+ setKey(
153
+ _context: RepositoryContext,
154
+ resource: Writable<Customer>,
155
+ { key }: CustomerSetKeyAction,
156
+ ) {
157
+ resource.key = key;
158
+ }
159
+
150
160
  setLastName(
151
161
  _context: RepositoryContext,
152
162
  resource: Writable<Customer>,
@@ -155,6 +165,14 @@ export class CustomerUpdateHandler
155
165
  resource.lastName = lastName;
156
166
  }
157
167
 
168
+ setSalutation(
169
+ _context: RepositoryContext,
170
+ resource: Writable<Customer>,
171
+ { salutation }: CustomerSetSalutationAction,
172
+ ) {
173
+ resource.salutation = salutation;
174
+ }
175
+
158
176
  setVatId(
159
177
  _context: RepositoryContext,
160
178
  resource: Writable<Customer>,
@@ -10,6 +10,7 @@ import type {
10
10
  OrderSetCustomFieldAction,
11
11
  OrderSetCustomTypeAction,
12
12
  OrderSetCustomerEmailAction,
13
+ OrderSetCustomerIdAction,
13
14
  OrderSetLocaleAction,
14
15
  OrderSetOrderNumberAction,
15
16
  OrderSetShippingAddressAction,
@@ -134,6 +135,14 @@ export class OrderUpdateHandler
134
135
  resource.customerEmail = email;
135
136
  }
136
137
 
138
+ setCustomerId(
139
+ context: RepositoryContext,
140
+ resource: Writable<Order>,
141
+ { customerId }: OrderSetCustomerIdAction,
142
+ ) {
143
+ resource.customerId = customerId;
144
+ }
145
+
137
146
  setCustomField(
138
147
  context: RepositoryContext,
139
148
  resource: Order,
@@ -217,6 +217,26 @@ describe("Customer Update Actions", () => {
217
217
  expect(response.body.lastName).toBe("Smith");
218
218
  });
219
219
 
220
+ test("setSalutation", async () => {
221
+ assert(customer, "customer not created");
222
+
223
+ customer = {
224
+ ...customer,
225
+ salutation: "Mr.",
226
+ };
227
+ ctMock.project("dummy").add("customer", customer);
228
+
229
+ const response = await supertest(ctMock.app)
230
+ .post(`/dummy/customers/${customer.id}`)
231
+ .send({
232
+ version: 1,
233
+ actions: [{ action: "setSalutation", salutation: "Mrs." }],
234
+ });
235
+ expect(response.status).toBe(200);
236
+ expect(response.body.version).toBe(2);
237
+ expect(response.body.salutation).toBe("Mrs.");
238
+ });
239
+
220
240
  test("setCompanyName", async () => {
221
241
  assert(customer, "customer not created");
222
242
 
@@ -370,4 +390,20 @@ describe("Customer Update Actions", () => {
370
390
  "A Customer number already exists and cannot be set again.",
371
391
  );
372
392
  });
393
+
394
+ test("setKey", async () => {
395
+ assert(customer, "customer not created");
396
+
397
+ ctMock.project("dummy").add("customer", customer);
398
+
399
+ const response = await supertest(ctMock.app)
400
+ .post(`/dummy/customers/${customer.id}`)
401
+ .send({
402
+ version: 1,
403
+ actions: [{ action: "setKey", key: "C001" }],
404
+ });
405
+ expect(response.status).toBe(200);
406
+ expect(response.body.version).toBe(2);
407
+ expect(response.body.key).toBe("C001");
408
+ });
373
409
  });
@@ -321,6 +321,41 @@ describe("Order Update Actions", () => {
321
321
  expect(responseAgain.body.locale).toBe("nl-NL");
322
322
  });
323
323
 
324
+ test("setCustomerEmail", async () => {
325
+ assert(order, "order not created");
326
+
327
+ const response = await supertest(ctMock.app)
328
+ .post(`/dummy/orders/${order.id}`)
329
+ .send({
330
+ version: 1,
331
+ actions: [{ action: "setCustomerEmail", email: "john@doe.com" }],
332
+ });
333
+ expect(response.status).toBe(200);
334
+ expect(response.body.version).toBe(2);
335
+ expect(response.body.customerEmail).toBe("john@doe.com");
336
+ });
337
+
338
+ test("setCustomerId", async () => {
339
+ assert(order, "order not created");
340
+
341
+ const response = await supertest(ctMock.app)
342
+ .post(`/dummy/orders/${order.id}`)
343
+ .send({
344
+ version: 1,
345
+ actions: [
346
+ {
347
+ action: "setCustomerId",
348
+ customerId: "9e3479fc-cc92-4d10-820a-a080b45ddcc1",
349
+ },
350
+ ],
351
+ });
352
+ expect(response.status).toBe(200);
353
+ expect(response.body.version).toBe(2);
354
+ expect(response.body.customerId).toBe(
355
+ "9e3479fc-cc92-4d10-820a-a080b45ddcc1",
356
+ );
357
+ });
358
+
324
359
  test("setOrderNumber", async () => {
325
360
  assert(order, "order not created");
326
361