@labdigital/commercetools-mock 2.22.1 → 2.23.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.22.1",
3
+ "version": "2.23.0",
4
4
  "license": "MIT",
5
5
  "author": "Michael van Tellingen",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "basic-auth": "^2.0.1",
23
23
  "body-parser": "^1.20.2",
24
24
  "deep-equal": "^2.2.3",
25
- "express": "^4.18.2",
25
+ "express": "^4.19.2",
26
26
  "light-my-request": "^5.11.1",
27
27
  "lodash.isequal": "^4.5.0",
28
28
  "morgan": "^1.10.0",
@@ -127,6 +127,7 @@ describe("Predicate filter", () => {
127
127
  expect(match(`numberProperty >= 1234`)).toBeTruthy();
128
128
  expect(match(`numberProperty >= 1235`)).toBeFalsy();
129
129
  });
130
+
130
131
  test("numberProperty < ...", async () => {
131
132
  expect(match(`numberProperty < 1235`)).toBeTruthy();
132
133
  expect(match(`numberProperty < 1234`)).toBeFalsy();
@@ -180,6 +181,16 @@ describe("Predicate filter", () => {
180
181
  expect(match(`nested(array(stringProperty="bar"))`)).toBeTruthy();
181
182
  expect(match(`nested(array(stringProperty="foobar"))`)).toBeFalsy();
182
183
 
184
+ // Different comparison operators
185
+ expect(match(`nested(array(numberProperty>=2345))`)).toBeTruthy();
186
+ expect(match(`nested(array(numberProperty>=2346))`)).toBeFalsy();
187
+ expect(match(`nested(array(numberProperty>2344))`)).toBeTruthy();
188
+ expect(match(`nested(array(numberProperty>2345))`)).toBeFalsy();
189
+ expect(match(`nested(array(numberProperty<=1234))`)).toBeTruthy();
190
+ expect(match(`nested(array(numberProperty<=1233))`)).toBeFalsy();
191
+ expect(match(`nested(array(numberProperty<1235))`)).toBeTruthy();
192
+ expect(match(`nested(array(numberProperty<1234))`)).toBeFalsy();
193
+
183
194
  // One level deeper
184
195
  expect(
185
196
  match(`nested(array(objectProperty(stringProperty="foo")))`),
@@ -192,6 +203,35 @@ describe("Predicate filter", () => {
192
203
  ).toBeFalsy();
193
204
  });
194
205
 
206
+ test("nested array multiple filters on property", async () => {
207
+ expect(
208
+ match(
209
+ `nested(array(stringProperty="foo" and numberProperty=2345 and objectProperty(stringProperty="foo")))`,
210
+ ),
211
+ ).toBeFalsy();
212
+ expect(
213
+ match(`nested(array(stringProperty="foo" or numberProperty=2345))`),
214
+ ).toBeTruthy();
215
+ expect(
216
+ match(
217
+ `nested(array(stringProperty="foo" and numberProperty > 1233 and numberProperty < 1235))`,
218
+ ),
219
+ ).toBeTruthy();
220
+ expect(
221
+ match(
222
+ `nested(array(stringProperty="foo" and numberProperty >= 1234 and numberProperty <= 1234))`,
223
+ ),
224
+ ).toBeTruthy();
225
+ expect(
226
+ match(`nested(array(stringProperty="foo" and numberProperty != 1233))`),
227
+ ).toBeTruthy();
228
+ expect(
229
+ match(
230
+ `nested(array(stringProperty="foobar" and numberProperty > 1234 and numberProperty < 1237))`,
231
+ ),
232
+ ).toBeFalsy();
233
+ });
234
+
195
235
  test("array filters on property", async () => {
196
236
  expect(match(`array(nestedArray(stringProperty="foo")))`)).toBeTruthy();
197
237
  expect(
@@ -259,6 +259,10 @@ const generateMatchFunc = (predicate: string): MatchFunc => {
259
259
  } else {
260
260
  const value = resolveValue(obj, left);
261
261
  if (value) {
262
+ if (Array.isArray(value)) {
263
+ return value.some((item) => expr(item, vars));
264
+ }
265
+
262
266
  return expr(value, vars);
263
267
  }
264
268
  return false;
@@ -98,10 +98,13 @@ export class CustomerRepository extends AbstractResourceRepository<"customer"> {
98
98
  }
99
99
  const expiresAt = new Date(Date.now() + 30 * 60);
100
100
  const customer = results.results[0] as Customer;
101
- const { version: _, ...rest } = getBaseResourceProperties();
101
+ const rest = getBaseResourceProperties();
102
+
102
103
  const token = createPasswordResetToken(customer);
103
104
  return {
104
- ...rest,
105
+ id: rest.id,
106
+ createdAt: rest.createdAt,
107
+ lastModifiedAt: rest.lastModifiedAt,
105
108
  customerId: customer.id,
106
109
  expiresAt: expiresAt.toISOString(),
107
110
  value: token,