@labdigital/commercetools-mock 2.18.2 → 2.19.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/dist/index.cjs +6 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/repositories/customer/actions.ts +18 -0
- package/src/services/customer.test.ts +36 -0
package/package.json
CHANGED
|
@@ -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>,
|
|
@@ -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
|
});
|