@labdigital/commercetools-mock 0.5.15 → 0.5.16

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,5 +1,5 @@
1
1
  {
2
- "version": "0.5.15",
2
+ "version": "0.5.16",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -50,7 +50,8 @@ export class ProductProjectionRepository extends AbstractResourceRepository {
50
50
  }
51
51
 
52
52
  search(projectKey: string, query: ParsedQs) {
53
- const wherePredicate = parseFilterExpression(query.filter as any)
53
+ const filter = (query['filter.query'] ?? query.filter) as any
54
+ const wherePredicate = filter ? parseFilterExpression(filter) : undefined
54
55
 
55
56
  const results = this._storage.query(projectKey, this.getTypeId(), {
56
57
  where: wherePredicate,
@@ -66,8 +66,10 @@ describe('Product Projection', () => {
66
66
 
67
67
  expect(response.status).toBe(404)
68
68
  })
69
+ })
69
70
 
70
- test('Search product projection', async () => {
71
+ describe('Product Projection Search', () => {
72
+ beforeAll(() => {
71
73
  ctMock.project('dummy').add('product-projection', {
72
74
  id: '',
73
75
  version: 1,
@@ -83,7 +85,9 @@ describe('Product Projection', () => {
83
85
  lastModifiedAt: '',
84
86
  categories: [],
85
87
  })
88
+ })
86
89
 
90
+ test('Search product projection', async () => {
87
91
  const response = await supertest(ctMock.app).get(
88
92
  '/dummy/product-projections/search?' +
89
93
  qs.stringify({
@@ -113,4 +117,31 @@ describe('Product Projection', () => {
113
117
  ],
114
118
  })
115
119
  })
120
+
121
+ test('Search product projection with query.filter', async () => {
122
+ const response = await supertest(ctMock.app).get(
123
+ '/dummy/product-projections/search?' +
124
+ qs.stringify({
125
+ 'query.filter': ['masterVariant.sku:"1337"'],
126
+ })
127
+ )
128
+
129
+ const projection: ProductProjection = response.body
130
+ expect(projection).toMatchObject({
131
+ count: 1,
132
+ results: [{ masterVariant: { id: 1, sku: '1337' } }],
133
+ })
134
+ })
135
+
136
+ test('Search product projection without filter', async () => {
137
+ const response = await supertest(ctMock.app).get(
138
+ '/dummy/product-projections/search'
139
+ )
140
+
141
+ const projection: ProductProjection = response.body
142
+ expect(projection).toMatchObject({
143
+ count: 1,
144
+ results: [{ masterVariant: { id: 1, sku: '1337' } }],
145
+ })
146
+ })
116
147
  })