@labdigital/commercetools-mock 2.24.0 → 2.26.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 +40 -0
package/package.json
CHANGED
|
@@ -6,9 +6,11 @@ import type {
|
|
|
6
6
|
CustomerSetCompanyNameAction,
|
|
7
7
|
CustomerSetCustomFieldAction,
|
|
8
8
|
CustomerSetCustomerNumberAction,
|
|
9
|
+
CustomerSetExternalIdAction,
|
|
9
10
|
CustomerSetFirstNameAction,
|
|
10
11
|
CustomerSetKeyAction,
|
|
11
12
|
CustomerSetLastNameAction,
|
|
13
|
+
CustomerSetLocaleAction,
|
|
12
14
|
CustomerSetSalutationAction,
|
|
13
15
|
CustomerSetVatIdAction,
|
|
14
16
|
CustomerUpdateAction,
|
|
@@ -141,6 +143,14 @@ export class CustomerUpdateHandler
|
|
|
141
143
|
resource.custom.fields[name] = value;
|
|
142
144
|
}
|
|
143
145
|
|
|
146
|
+
setExternalId(
|
|
147
|
+
_context: RepositoryContext,
|
|
148
|
+
resource: Writable<Customer>,
|
|
149
|
+
{ externalId }: CustomerSetExternalIdAction,
|
|
150
|
+
) {
|
|
151
|
+
resource.externalId = externalId;
|
|
152
|
+
}
|
|
153
|
+
|
|
144
154
|
setFirstName(
|
|
145
155
|
_context: RepositoryContext,
|
|
146
156
|
resource: Writable<Customer>,
|
|
@@ -165,6 +175,14 @@ export class CustomerUpdateHandler
|
|
|
165
175
|
resource.lastName = lastName;
|
|
166
176
|
}
|
|
167
177
|
|
|
178
|
+
setLocale(
|
|
179
|
+
_context: RepositoryContext,
|
|
180
|
+
resource: Writable<Customer>,
|
|
181
|
+
{ locale }: CustomerSetLocaleAction,
|
|
182
|
+
) {
|
|
183
|
+
resource.locale = locale;
|
|
184
|
+
}
|
|
185
|
+
|
|
168
186
|
setSalutation(
|
|
169
187
|
_context: RepositoryContext,
|
|
170
188
|
resource: Writable<Customer>,
|
|
@@ -177,6 +177,26 @@ describe("Customer Update Actions", () => {
|
|
|
177
177
|
expect(response.body.custom.fields.isValidCouponCode).toBe(false);
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
+
test("setExternalId", async () => {
|
|
181
|
+
assert(customer, "customer not created");
|
|
182
|
+
|
|
183
|
+
customer = {
|
|
184
|
+
...customer,
|
|
185
|
+
firstName: "John",
|
|
186
|
+
};
|
|
187
|
+
ctMock.project("dummy").add("customer", customer);
|
|
188
|
+
|
|
189
|
+
const response = await supertest(ctMock.app)
|
|
190
|
+
.post(`/dummy/customers/${customer.id}`)
|
|
191
|
+
.send({
|
|
192
|
+
version: 1,
|
|
193
|
+
actions: [{ action: "setExternalId", externalId: "123-xx-123" }],
|
|
194
|
+
});
|
|
195
|
+
expect(response.status).toBe(200);
|
|
196
|
+
expect(response.body.version).toBe(2);
|
|
197
|
+
expect(response.body.externalId).toBe("123-xx-123");
|
|
198
|
+
});
|
|
199
|
+
|
|
180
200
|
test("setFirstName", async () => {
|
|
181
201
|
assert(customer, "customer not created");
|
|
182
202
|
|
|
@@ -217,6 +237,26 @@ describe("Customer Update Actions", () => {
|
|
|
217
237
|
expect(response.body.lastName).toBe("Smith");
|
|
218
238
|
});
|
|
219
239
|
|
|
240
|
+
test("setLocale", async () => {
|
|
241
|
+
assert(customer, "customer not created");
|
|
242
|
+
|
|
243
|
+
customer = {
|
|
244
|
+
...customer,
|
|
245
|
+
salutation: "Mr.",
|
|
246
|
+
};
|
|
247
|
+
ctMock.project("dummy").add("customer", customer);
|
|
248
|
+
|
|
249
|
+
const response = await supertest(ctMock.app)
|
|
250
|
+
.post(`/dummy/customers/${customer.id}`)
|
|
251
|
+
.send({
|
|
252
|
+
version: 1,
|
|
253
|
+
actions: [{ action: "setLocale", locale: "de-DE" }],
|
|
254
|
+
});
|
|
255
|
+
expect(response.status).toBe(200);
|
|
256
|
+
expect(response.body.version).toBe(2);
|
|
257
|
+
expect(response.body.locale).toBe("de-DE");
|
|
258
|
+
});
|
|
259
|
+
|
|
220
260
|
test("setSalutation", async () => {
|
|
221
261
|
assert(customer, "customer not created");
|
|
222
262
|
|