@labdigital/commercetools-mock 0.5.16 → 0.5.17

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.
@@ -4,6 +4,8 @@ import { AbstractStorage } from '../storage';
4
4
  export declare type QueryParams = {
5
5
  expand?: string[];
6
6
  where?: string[];
7
+ offset?: number;
8
+ limit?: number;
7
9
  };
8
10
  export declare type GetParams = {
9
11
  expand?: string[];
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.5.16",
2
+ "version": "0.5.17",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -14,6 +14,8 @@ import { CommercetoolsError } from '../exceptions'
14
14
  export type QueryParams = {
15
15
  expand?: string[]
16
16
  where?: string[]
17
+ offset?: number
18
+ limit?: number
17
19
  }
18
20
 
19
21
  export type GetParams = {
@@ -69,6 +71,8 @@ export abstract class AbstractResourceRepository extends AbstractRepository {
69
71
  return this._storage.query(projectKey, this.getTypeId(), {
70
72
  expand: params.expand,
71
73
  where: params.where,
74
+ offset: params.offset,
75
+ limit: params.limit,
72
76
  })
73
77
  }
74
78
 
@@ -55,6 +55,8 @@ export class ProductProjectionRepository extends AbstractResourceRepository {
55
55
 
56
56
  const results = this._storage.query(projectKey, this.getTypeId(), {
57
57
  where: wherePredicate,
58
+ offset: query.offset ? Number(query.offset) : undefined,
59
+ limit: query.limit ? Number(query.limit) : undefined,
58
60
  }) //TODO: this is a partial implementation, but I don't really have the time to implement an actual search API right now
59
61
 
60
62
  return results
@@ -37,9 +37,14 @@ export default abstract class AbstractService {
37
37
  }
38
38
 
39
39
  get(request: Request, response: Response) {
40
+ const limit = this._parseParam(request.query.limit)
41
+ const offset = this._parseParam(request.query.offset)
42
+
40
43
  const result = this.repository.query(request.params.projectKey, {
41
44
  expand: this._parseParam(request.query.expand),
42
45
  where: this._parseParam(request.query.where),
46
+ limit: limit !== undefined ? Number(limit) : undefined,
47
+ offset: offset !== undefined ? Number(offset) : undefined,
43
48
  })
44
49
  return response.status(200).send(result)
45
50
  }
@@ -118,6 +118,26 @@ describe('Product Projection Search', () => {
118
118
  })
119
119
  })
120
120
 
121
+ test('Search product projection page 2', async () => {
122
+ const response = await supertest(ctMock.app).get(
123
+ '/dummy/product-projections/search?' +
124
+ qs.stringify({
125
+ filter: ['masterVariant.sku:"1337"'],
126
+ limit: 50,
127
+ offset: 100,
128
+ })
129
+ )
130
+
131
+ const projection: ProductProjection = response.body
132
+ expect(projection).toEqual({
133
+ count: 1,
134
+ limit: 50,
135
+ offset: 100,
136
+ total: 0,
137
+ results: [],
138
+ })
139
+ })
140
+
121
141
  test('Search product projection with query.filter', async () => {
122
142
  const response = await supertest(ctMock.app).get(
123
143
  '/dummy/product-projections/search?' +