@labdigital/commercetools-mock 2.17.1 → 2.18.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.
Files changed (178) hide show
  1. package/dist/index.cjs +4186 -3974
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/index.d.cts +266 -413
  4. package/dist/index.d.ts +266 -413
  5. package/dist/index.js +4186 -3974
  6. package/dist/index.js.map +1 -1
  7. package/package.json +44 -46
  8. package/src/constants.ts +2 -2
  9. package/src/ctMock.test.ts +11 -11
  10. package/src/ctMock.ts +141 -127
  11. package/src/deprecation.ts +8 -0
  12. package/src/exceptions.ts +17 -15
  13. package/src/helpers.ts +32 -32
  14. package/src/index.test.ts +128 -128
  15. package/src/index.ts +3 -3
  16. package/src/lib/expandParser.ts +13 -13
  17. package/src/lib/haversine.test.ts +9 -9
  18. package/src/lib/haversine.ts +11 -11
  19. package/src/lib/masking.ts +11 -11
  20. package/src/lib/parser.ts +2 -2
  21. package/src/lib/password.ts +23 -3
  22. package/src/lib/predicateParser.test.ts +185 -183
  23. package/src/lib/predicateParser.ts +234 -234
  24. package/src/lib/projectionSearchFilter.test.ts +103 -101
  25. package/src/lib/projectionSearchFilter.ts +152 -150
  26. package/src/lib/proxy.ts +5 -5
  27. package/src/oauth/errors.ts +4 -4
  28. package/src/oauth/helpers.ts +6 -6
  29. package/src/oauth/server.test.ts +86 -86
  30. package/src/oauth/server.ts +158 -144
  31. package/src/oauth/store.ts +44 -43
  32. package/src/priceSelector.test.ts +35 -35
  33. package/src/priceSelector.ts +30 -30
  34. package/src/product-projection-search.ts +136 -134
  35. package/src/projectAPI.test.ts +7 -7
  36. package/src/projectAPI.ts +24 -22
  37. package/src/repositories/abstract.ts +168 -116
  38. package/src/repositories/associate-role.ts +90 -77
  39. package/src/repositories/attribute-group.ts +51 -40
  40. package/src/repositories/business-unit.ts +168 -148
  41. package/src/repositories/cart/actions.ts +489 -0
  42. package/src/repositories/cart/helpers.ts +30 -0
  43. package/src/repositories/cart/index.ts +180 -0
  44. package/src/repositories/cart-discount/actions.ts +148 -0
  45. package/src/repositories/cart-discount/index.ts +86 -0
  46. package/src/repositories/category/actions.ts +231 -0
  47. package/src/repositories/category/index.ts +52 -0
  48. package/src/repositories/channel.ts +88 -90
  49. package/src/repositories/custom-object.ts +46 -45
  50. package/src/repositories/customer/actions.ts +165 -0
  51. package/src/repositories/customer/index.ts +79 -0
  52. package/src/repositories/customer-group.ts +66 -55
  53. package/src/repositories/discount-code/actions.ts +149 -0
  54. package/src/repositories/discount-code/index.ts +50 -0
  55. package/src/repositories/errors.ts +10 -10
  56. package/src/repositories/extension.ts +64 -62
  57. package/src/repositories/helpers.ts +117 -118
  58. package/src/repositories/index.ts +80 -79
  59. package/src/repositories/inventory-entry/actions.ts +84 -0
  60. package/src/repositories/inventory-entry/index.ts +44 -0
  61. package/src/repositories/my-customer.ts +114 -0
  62. package/src/repositories/my-order.ts +8 -8
  63. package/src/repositories/order/actions.ts +281 -0
  64. package/src/repositories/{order.test.ts → order/index.test.ts} +77 -77
  65. package/src/repositories/order/index.ts +260 -0
  66. package/src/repositories/order-edit.ts +10 -23
  67. package/src/repositories/payment/actions.ts +305 -0
  68. package/src/repositories/payment/helpers.ts +17 -0
  69. package/src/repositories/payment/index.ts +56 -0
  70. package/src/repositories/product/actions.ts +943 -0
  71. package/src/repositories/product/helpers.ts +98 -0
  72. package/src/repositories/product/index.ts +130 -0
  73. package/src/repositories/product-discount.ts +127 -117
  74. package/src/repositories/product-projection.ts +56 -62
  75. package/src/repositories/product-selection.ts +31 -28
  76. package/src/repositories/product-type.ts +136 -134
  77. package/src/repositories/project.ts +133 -118
  78. package/src/repositories/quote-request.ts +7 -19
  79. package/src/repositories/quote.ts +7 -22
  80. package/src/repositories/review.ts +13 -26
  81. package/src/repositories/shipping-method/actions.ts +198 -0
  82. package/src/repositories/shipping-method/helpers.ts +10 -0
  83. package/src/repositories/shipping-method/index.ts +138 -0
  84. package/src/repositories/shopping-list/actions.ts +295 -0
  85. package/src/repositories/shopping-list/index.ts +122 -0
  86. package/src/repositories/staged-quote.ts +7 -20
  87. package/src/repositories/standalone-price.ts +57 -44
  88. package/src/repositories/state.ts +113 -68
  89. package/src/repositories/store.ts +106 -94
  90. package/src/repositories/subscription.ts +46 -22
  91. package/src/repositories/tax-category/actions.ts +94 -0
  92. package/src/repositories/tax-category/helpers.ts +8 -0
  93. package/src/repositories/tax-category/index.ts +25 -0
  94. package/src/repositories/type/actions.ts +162 -0
  95. package/src/repositories/type/index.ts +24 -0
  96. package/src/repositories/zone.ts +62 -58
  97. package/src/server.ts +9 -9
  98. package/src/services/abstract.ts +75 -72
  99. package/src/services/associate-roles.test.ts +27 -27
  100. package/src/services/associate-roles.ts +7 -7
  101. package/src/services/attribute-group.ts +7 -7
  102. package/src/services/business-units.test.ts +28 -28
  103. package/src/services/business-units.ts +7 -7
  104. package/src/services/cart-discount.test.ts +199 -199
  105. package/src/services/cart-discount.ts +7 -7
  106. package/src/services/cart.test.ts +261 -261
  107. package/src/services/cart.ts +22 -21
  108. package/src/services/category.test.ts +121 -121
  109. package/src/services/category.ts +7 -7
  110. package/src/services/channel.ts +7 -7
  111. package/src/services/custom-object.test.ts +130 -130
  112. package/src/services/custom-object.ts +34 -31
  113. package/src/services/customer-group.ts +7 -7
  114. package/src/services/customer.test.ts +205 -205
  115. package/src/services/customer.ts +23 -36
  116. package/src/services/discount-code.ts +7 -7
  117. package/src/services/extension.ts +7 -7
  118. package/src/services/index.ts +85 -81
  119. package/src/services/inventory-entry.test.ts +106 -106
  120. package/src/services/inventory-entry.ts +7 -7
  121. package/src/services/my-cart.test.ts +56 -56
  122. package/src/services/my-cart.ts +20 -20
  123. package/src/services/my-customer.test.ts +155 -104
  124. package/src/services/my-customer.ts +61 -75
  125. package/src/services/my-order.ts +16 -16
  126. package/src/services/my-payment.test.ts +40 -40
  127. package/src/services/my-payment.ts +7 -7
  128. package/src/services/my-shopping-list.ts +7 -7
  129. package/src/services/order.test.ts +243 -243
  130. package/src/services/order.ts +23 -18
  131. package/src/services/payment.test.ts +40 -40
  132. package/src/services/payment.ts +7 -7
  133. package/src/services/product-discount.ts +7 -7
  134. package/src/services/product-projection.test.ts +190 -190
  135. package/src/services/product-projection.ts +34 -32
  136. package/src/services/product-selection.test.ts +19 -19
  137. package/src/services/product-selection.ts +7 -7
  138. package/src/services/product-type.test.ts +38 -38
  139. package/src/services/product-type.ts +7 -7
  140. package/src/services/product.test.ts +658 -656
  141. package/src/services/product.ts +7 -7
  142. package/src/services/project.test.ts +24 -24
  143. package/src/services/project.ts +17 -17
  144. package/src/services/reviews.ts +7 -7
  145. package/src/services/shipping-method.test.ts +78 -78
  146. package/src/services/shipping-method.ts +16 -16
  147. package/src/services/shopping-list.test.ts +170 -170
  148. package/src/services/shopping-list.ts +7 -7
  149. package/src/services/standalone-price.test.ts +112 -112
  150. package/src/services/standalone-price.ts +7 -7
  151. package/src/services/state.test.ts +30 -30
  152. package/src/services/state.ts +7 -7
  153. package/src/services/store.test.ts +40 -40
  154. package/src/services/store.ts +7 -7
  155. package/src/services/subscription.ts +7 -7
  156. package/src/services/tax-category.test.ts +43 -43
  157. package/src/services/tax-category.ts +7 -7
  158. package/src/services/type.ts +7 -7
  159. package/src/services/zone.ts +7 -7
  160. package/src/shippingCalculator.test.ts +43 -43
  161. package/src/shippingCalculator.ts +23 -23
  162. package/src/storage/abstract.ts +36 -34
  163. package/src/storage/in-memory.ts +237 -233
  164. package/src/storage/index.ts +2 -2
  165. package/src/types.ts +91 -91
  166. package/src/repositories/cart-discount.ts +0 -219
  167. package/src/repositories/cart.ts +0 -659
  168. package/src/repositories/category.ts +0 -256
  169. package/src/repositories/customer.ts +0 -228
  170. package/src/repositories/discount-code.ts +0 -181
  171. package/src/repositories/inventory-entry.ts +0 -109
  172. package/src/repositories/order.ts +0 -514
  173. package/src/repositories/payment.ts +0 -342
  174. package/src/repositories/product.ts +0 -1106
  175. package/src/repositories/shipping-method.ts +0 -312
  176. package/src/repositories/shopping-list.ts +0 -392
  177. package/src/repositories/tax-category.ts +0 -111
  178. package/src/repositories/type.ts +0 -172
@@ -5,156 +5,156 @@ import type {
5
5
  ProductProjectionPagedSearchResponse,
6
6
  ProductType,
7
7
  ProductTypeDraft,
8
- } from '@commercetools/platform-sdk'
9
- import supertest from 'supertest'
10
- import * as timekeeper from 'timekeeper'
11
- import { afterEach, beforeEach, describe, expect, test } from 'vitest'
12
- import { CommercetoolsMock } from '../index.js'
13
- import { Writable } from '../types.js'
8
+ } from "@commercetools/platform-sdk";
9
+ import supertest from "supertest";
10
+ import * as timekeeper from "timekeeper";
11
+ import { afterEach, beforeEach, describe, expect, test } from "vitest";
12
+ import { CommercetoolsMock } from "../index";
13
+ import { Writable } from "../types";
14
14
 
15
- const ctMock = new CommercetoolsMock()
15
+ const ctMock = new CommercetoolsMock();
16
16
 
17
- let productType: ProductType
18
- let productProjection: ProductProjection
19
- let publishedProduct: Product
20
- let unpublishedProduct: Product
17
+ let productType: ProductType;
18
+ let productProjection: ProductProjection;
19
+ let publishedProduct: Product;
20
+ let unpublishedProduct: Product;
21
21
 
22
22
  beforeEach(async () => {
23
- timekeeper.freeze(new Date('2022-07-22T13:31:49.840Z'))
23
+ timekeeper.freeze(new Date("2022-07-22T13:31:49.840Z"));
24
24
 
25
25
  // Create the product type
26
26
  {
27
27
  const draft: ProductTypeDraft = {
28
- name: 'Default Product Type',
29
- description: 'Product type for testing',
30
- }
28
+ name: "Default Product Type",
29
+ description: "Product type for testing",
30
+ };
31
31
  const response = await supertest(ctMock.app)
32
- .post('/dummy/product-types')
33
- .send(draft)
32
+ .post("/dummy/product-types")
33
+ .send(draft);
34
34
 
35
- expect(response.ok).toBe(true)
36
- productType = response.body
35
+ expect(response.ok).toBe(true);
36
+ productType = response.body;
37
37
  }
38
38
 
39
39
  // Create an unpublished product
40
40
  {
41
41
  const productDraft: Writable<ProductDraft> = {
42
42
  publish: false,
43
- key: 'my-unpublished-product',
43
+ key: "my-unpublished-product",
44
44
  masterVariant: {
45
- sku: 'my-unpub-sku',
45
+ sku: "my-unpub-sku",
46
46
  prices: [
47
47
  {
48
48
  value: {
49
- currencyCode: 'EUR',
49
+ currencyCode: "EUR",
50
50
  centAmount: 189,
51
51
  },
52
52
  },
53
53
  ],
54
54
  attributes: [
55
55
  {
56
- name: 'number',
56
+ name: "number",
57
57
  value: 1 as any,
58
58
  },
59
59
  ],
60
60
  },
61
61
  name: {
62
- 'nl-NL': 'test unpublished product',
62
+ "nl-NL": "test unpublished product",
63
63
  },
64
64
  productType: {
65
- typeId: 'product-type',
65
+ typeId: "product-type",
66
66
  id: productType.id,
67
67
  },
68
68
  slug: {
69
- 'nl-NL': 'test-unpublished-product',
69
+ "nl-NL": "test-unpublished-product",
70
70
  },
71
- }
71
+ };
72
72
 
73
73
  const response = await supertest(ctMock.app)
74
- .post('/dummy/products')
75
- .send(productDraft)
76
- expect(response.ok).toBe(true)
77
- unpublishedProduct = response.body
74
+ .post("/dummy/products")
75
+ .send(productDraft);
76
+ expect(response.ok).toBe(true);
77
+ unpublishedProduct = response.body;
78
78
  }
79
79
 
80
80
  // Create a published product
81
81
  {
82
82
  const productDraft: Writable<ProductDraft> = {
83
83
  publish: true,
84
- key: 'my-product-key',
84
+ key: "my-product-key",
85
85
  masterVariant: {
86
- sku: 'my-sku',
86
+ sku: "my-sku",
87
87
  prices: [
88
88
  {
89
89
  value: {
90
- currencyCode: 'EUR',
90
+ currencyCode: "EUR",
91
91
  centAmount: 1789,
92
92
  },
93
93
  },
94
94
  ],
95
95
  attributes: [
96
96
  {
97
- name: 'number',
97
+ name: "number",
98
98
  value: 4 as any,
99
99
  },
100
100
  ],
101
101
  },
102
102
  variants: [
103
103
  {
104
- sku: 'my-other-sku',
104
+ sku: "my-other-sku",
105
105
  prices: [
106
106
  {
107
107
  value: {
108
- currencyCode: 'EUR',
108
+ currencyCode: "EUR",
109
109
  centAmount: 91789,
110
110
  },
111
111
  },
112
112
  ],
113
113
  attributes: [
114
114
  {
115
- name: 'number',
115
+ name: "number",
116
116
  value: 50 as any,
117
117
  },
118
118
  ],
119
119
  },
120
120
  ],
121
121
  name: {
122
- 'nl-NL': 'test product',
122
+ "nl-NL": "test product",
123
123
  },
124
124
  productType: {
125
- typeId: 'product-type',
125
+ typeId: "product-type",
126
126
  id: productType.id,
127
127
  },
128
128
  slug: {
129
- 'nl-NL': 'test-product',
129
+ "nl-NL": "test-product",
130
130
  },
131
- }
131
+ };
132
132
 
133
133
  const response = await supertest(ctMock.app)
134
- .post('/dummy/products')
135
- .send(productDraft)
136
- expect(response.ok).toBe(true)
137
- const product = response.body
138
- publishedProduct = response.body
134
+ .post("/dummy/products")
135
+ .send(productDraft);
136
+ expect(response.ok).toBe(true);
137
+ const product = response.body;
138
+ publishedProduct = response.body;
139
139
 
140
140
  // Create the expected ProductProjection object
141
141
  productProjection = {
142
142
  id: product.id,
143
- createdAt: '2022-07-22T13:31:49.840Z',
144
- lastModifiedAt: '2022-07-22T13:31:49.840Z',
143
+ createdAt: "2022-07-22T13:31:49.840Z",
144
+ lastModifiedAt: "2022-07-22T13:31:49.840Z",
145
145
  version: 1,
146
- key: 'my-product-key',
146
+ key: "my-product-key",
147
147
  published: true,
148
148
  hasStagedChanges: false,
149
149
  masterVariant: {
150
150
  id: 1,
151
- sku: 'my-sku',
151
+ sku: "my-sku",
152
152
  prices: [
153
153
  {
154
154
  id: product.masterData.current.masterVariant.prices[0].id,
155
155
  value: {
156
- type: 'centPrecision',
157
- currencyCode: 'EUR',
156
+ type: "centPrecision",
157
+ currencyCode: "EUR",
158
158
  centAmount: 1789,
159
159
  fractionDigits: 2,
160
160
  },
@@ -167,13 +167,13 @@ beforeEach(async () => {
167
167
  variants: [
168
168
  {
169
169
  id: 2,
170
- sku: 'my-other-sku',
170
+ sku: "my-other-sku",
171
171
  prices: [
172
172
  {
173
173
  id: product.masterData.current.variants[0].prices[0].id,
174
174
  value: {
175
- type: 'centPrecision',
176
- currencyCode: 'EUR',
175
+ type: "centPrecision",
176
+ currencyCode: "EUR",
177
177
  centAmount: 91789,
178
178
  fractionDigits: 2,
179
179
  },
@@ -188,103 +188,103 @@ beforeEach(async () => {
188
188
  slug: productDraft.slug,
189
189
  categories: [],
190
190
  productType: {
191
- typeId: 'product-type',
191
+ typeId: "product-type",
192
192
  id: productType.id,
193
193
  },
194
- }
194
+ };
195
195
  }
196
- })
196
+ });
197
197
 
198
198
  afterEach(async () => {
199
- timekeeper.reset()
200
- ctMock.clear()
201
- })
199
+ timekeeper.reset();
200
+ ctMock.clear();
201
+ });
202
202
  // Test the general product projection implementation
203
- describe('Product Projection Get By ID', () => {
204
- test('Get By ID', async () => {
203
+ describe("Product Projection Get By ID", () => {
204
+ test("Get By ID", async () => {
205
205
  const response = await supertest(ctMock.app).get(
206
- `/dummy/product-projections/${publishedProduct.id}`
207
- )
206
+ `/dummy/product-projections/${publishedProduct.id}`,
207
+ );
208
208
 
209
- const result: ProductProjection = response.body
210
- expect(result).toBeDefined()
211
- expect(result.id).toBe(publishedProduct.id)
212
- })
213
- })
209
+ const result: ProductProjection = response.body;
210
+ expect(result).toBeDefined();
211
+ expect(result.id).toBe(publishedProduct.id);
212
+ });
213
+ });
214
214
 
215
215
  // Test the general product projection implementation
216
- describe('Product Projection Query - Generic', () => {
217
- test('Filter out staged', async () => {
216
+ describe("Product Projection Query - Generic", () => {
217
+ test("Filter out staged", async () => {
218
218
  const response = await supertest(ctMock.app)
219
- .get('/dummy/product-projections')
219
+ .get("/dummy/product-projections")
220
220
  .query({
221
221
  limit: 50,
222
- })
222
+ });
223
223
 
224
- const result: ProductProjectionPagedSearchResponse = response.body
224
+ const result: ProductProjectionPagedSearchResponse = response.body;
225
225
  expect(result).toEqual({
226
226
  count: 1,
227
227
  limit: 50,
228
228
  offset: 0,
229
229
  total: 1,
230
230
  results: [productProjection],
231
- })
232
- })
231
+ });
232
+ });
233
233
 
234
- test('Filter on valid slug', async () => {
234
+ test("Filter on valid slug", async () => {
235
235
  {
236
236
  const response = await supertest(ctMock.app)
237
- .get('/dummy/product-projections')
237
+ .get("/dummy/product-projections")
238
238
  .query({
239
- limit: 50,
240
- where: ['slug(nl-NL=:slug)'],
241
- 'var.slug': 'test-product',
242
- })
239
+ "limit": 50,
240
+ "where": ["slug(nl-NL=:slug)"],
241
+ "var.slug": "test-product",
242
+ });
243
243
 
244
- const result: ProductProjectionPagedSearchResponse = response.body
244
+ const result: ProductProjectionPagedSearchResponse = response.body;
245
245
  expect(result).toEqual({
246
246
  count: 1,
247
247
  limit: 50,
248
248
  offset: 0,
249
249
  total: 1,
250
250
  results: [productProjection],
251
- })
251
+ });
252
252
  }
253
- })
253
+ });
254
254
 
255
- test('Filter on invalid slug', async () => {
255
+ test("Filter on invalid slug", async () => {
256
256
  {
257
257
  const response = await supertest(ctMock.app)
258
- .get('/dummy/product-projections')
258
+ .get("/dummy/product-projections")
259
259
  .query({
260
- limit: 50,
261
- where: ['slug(nl-NL=:slug)'],
262
- 'var.slug': 'missing-product',
263
- })
260
+ "limit": 50,
261
+ "where": ["slug(nl-NL=:slug)"],
262
+ "var.slug": "missing-product",
263
+ });
264
264
 
265
- const result: ProductProjectionPagedSearchResponse = response.body
265
+ const result: ProductProjectionPagedSearchResponse = response.body;
266
266
  expect(result).toEqual({
267
267
  count: 0,
268
268
  limit: 50,
269
269
  offset: 0,
270
270
  total: 0,
271
271
  results: [],
272
- })
272
+ });
273
273
  }
274
- })
275
- })
274
+ });
275
+ });
276
276
 
277
277
  // Test the general product projection implementation
278
- describe('Product Projection Search - Generic', () => {
279
- test('Pagination', async () => {
278
+ describe("Product Projection Search - Generic", () => {
279
+ test("Pagination", async () => {
280
280
  {
281
281
  const response = await supertest(ctMock.app)
282
- .get('/dummy/product-projections/search')
282
+ .get("/dummy/product-projections/search")
283
283
  .query({
284
284
  limit: 50,
285
- })
285
+ });
286
286
 
287
- const result: ProductProjectionPagedSearchResponse = response.body
287
+ const result: ProductProjectionPagedSearchResponse = response.body;
288
288
  expect(result).toEqual({
289
289
  count: 1,
290
290
  limit: 50,
@@ -292,17 +292,17 @@ describe('Product Projection Search - Generic', () => {
292
292
  total: 1,
293
293
  facets: {},
294
294
  results: [productProjection],
295
- })
295
+ });
296
296
  }
297
297
  {
298
298
  const response = await supertest(ctMock.app)
299
- .get('/dummy/product-projections/search')
299
+ .get("/dummy/product-projections/search")
300
300
  .query({
301
301
  limit: 50,
302
302
  offset: 50,
303
- })
303
+ });
304
304
 
305
- const projection: ProductProjection = response.body
305
+ const projection: ProductProjection = response.body;
306
306
  expect(projection).toEqual({
307
307
  count: 1,
308
308
  limit: 50,
@@ -310,20 +310,20 @@ describe('Product Projection Search - Generic', () => {
310
310
  total: 0,
311
311
  facets: {},
312
312
  results: [],
313
- })
313
+ });
314
314
  }
315
- })
315
+ });
316
316
 
317
- test('Search - unpublished', async () => {
317
+ test("Search - unpublished", async () => {
318
318
  {
319
319
  const response = await supertest(ctMock.app)
320
- .get('/dummy/product-projections/search')
320
+ .get("/dummy/product-projections/search")
321
321
  .query({
322
322
  limit: 50,
323
323
  staged: true,
324
- })
324
+ });
325
325
 
326
- const result: ProductProjectionPagedSearchResponse = response.body
326
+ const result: ProductProjectionPagedSearchResponse = response.body;
327
327
 
328
328
  expect(result).toMatchObject({
329
329
  count: 2,
@@ -335,97 +335,97 @@ describe('Product Projection Search - Generic', () => {
335
335
  { id: unpublishedProduct.id, published: false },
336
336
  { id: publishedProduct.id, published: true },
337
337
  ],
338
- })
338
+ });
339
339
  }
340
- })
340
+ });
341
341
 
342
- test('Get 404 when not found by key with expand', async () => {
342
+ test("Get 404 when not found by key with expand", async () => {
343
343
  const response = await supertest(ctMock.app)
344
- .get('/dummy/product-projections/key=DOESNOTEXIST')
344
+ .get("/dummy/product-projections/key=DOESNOTEXIST")
345
345
  .query({
346
- expand: ['categories[*]'],
347
- })
346
+ expand: ["categories[*]"],
347
+ });
348
348
 
349
- expect(response.status).toBe(404)
350
- })
351
- })
349
+ expect(response.status).toBe(404);
350
+ });
351
+ });
352
352
 
353
- describe('Product Projection Search - Filters', () => {
354
- test('variants.sku', async () => {
353
+ describe("Product Projection Search - Filters", () => {
354
+ test("variants.sku", async () => {
355
355
  const response = await supertest(ctMock.app)
356
- .get('/dummy/product-projections/search')
356
+ .get("/dummy/product-projections/search")
357
357
  .query({
358
358
  filter: ['variants.sku:"my-sku"'],
359
- })
359
+ });
360
360
 
361
- const result: ProductProjectionPagedSearchResponse = response.body
361
+ const result: ProductProjectionPagedSearchResponse = response.body;
362
362
  expect(result).toMatchObject({
363
363
  count: 1,
364
364
  results: [
365
365
  {
366
- masterVariant: { sku: 'my-sku' },
366
+ masterVariant: { sku: "my-sku" },
367
367
  },
368
368
  ],
369
- })
370
- })
369
+ });
370
+ });
371
371
 
372
- test('variants.attributes.range - match', async () => {
372
+ test("variants.attributes.range - match", async () => {
373
373
  const response = await supertest(ctMock.app)
374
- .get('/dummy/product-projections/search')
374
+ .get("/dummy/product-projections/search")
375
375
  .query({
376
- filter: ['variants.attributes.number:range(0 TO 10)'],
377
- })
376
+ filter: ["variants.attributes.number:range(0 TO 10)"],
377
+ });
378
378
 
379
- const result: ProductProjectionPagedSearchResponse = response.body
379
+ const result: ProductProjectionPagedSearchResponse = response.body;
380
380
  expect(result).toMatchObject({
381
381
  count: 1,
382
382
  results: [
383
383
  {
384
- masterVariant: { sku: 'my-sku' },
384
+ masterVariant: { sku: "my-sku" },
385
385
  },
386
386
  ],
387
- })
388
- })
387
+ });
388
+ });
389
389
 
390
- test('variants.attributes.range - mismatch', async () => {
390
+ test("variants.attributes.range - mismatch", async () => {
391
391
  const response = await supertest(ctMock.app)
392
- .get('/dummy/product-projections/search')
392
+ .get("/dummy/product-projections/search")
393
393
  .query({
394
- filter: ['variants.attributes.number:range(5 TO 10)'],
395
- })
394
+ filter: ["variants.attributes.number:range(5 TO 10)"],
395
+ });
396
396
 
397
- const result: ProductProjectionPagedSearchResponse = response.body
397
+ const result: ProductProjectionPagedSearchResponse = response.body;
398
398
  expect(result).toMatchObject({
399
399
  count: 0,
400
400
  results: [],
401
- })
402
- })
403
- })
401
+ });
402
+ });
403
+ });
404
404
 
405
- describe('Product Projection Search - Facets', () => {
406
- test('termExpr - variants.attributes.number', async () => {
405
+ describe("Product Projection Search - Facets", () => {
406
+ test("termExpr - variants.attributes.number", async () => {
407
407
  const response = await supertest(ctMock.app)
408
- .get('/dummy/product-projections/search')
408
+ .get("/dummy/product-projections/search")
409
409
  .query({
410
- facet: ['variants.attributes.number'],
411
- })
410
+ facet: ["variants.attributes.number"],
411
+ });
412
412
 
413
- const result: ProductProjectionPagedSearchResponse = response.body
413
+ const result: ProductProjectionPagedSearchResponse = response.body;
414
414
  expect(result).toMatchObject({
415
415
  count: 1,
416
416
  facets: {
417
- 'variants.attributes.number': {
418
- type: 'terms',
419
- dataType: 'text',
417
+ "variants.attributes.number": {
418
+ type: "terms",
419
+ dataType: "text",
420
420
  missing: 0,
421
421
  total: 2,
422
422
  terms: [
423
423
  {
424
- term: '4.0',
424
+ term: "4.0",
425
425
  count: 1,
426
426
  },
427
427
  {
428
- term: '50.0',
428
+ term: "50.0",
429
429
  count: 1,
430
430
  },
431
431
  ],
@@ -433,59 +433,59 @@ describe('Product Projection Search - Facets', () => {
433
433
  },
434
434
  results: [
435
435
  {
436
- masterVariant: { sku: 'my-sku' },
436
+ masterVariant: { sku: "my-sku" },
437
437
  },
438
438
  ],
439
- })
440
- })
439
+ });
440
+ });
441
441
 
442
- test('filterExpr - variants.attributes.number', async () => {
442
+ test("filterExpr - variants.attributes.number", async () => {
443
443
  const response = await supertest(ctMock.app)
444
- .get('/dummy/product-projections/search')
444
+ .get("/dummy/product-projections/search")
445
445
  .query({
446
- facet: ['variants.attributes.number:3,4'],
447
- })
446
+ facet: ["variants.attributes.number:3,4"],
447
+ });
448
448
 
449
- const result: ProductProjectionPagedSearchResponse = response.body
449
+ const result: ProductProjectionPagedSearchResponse = response.body;
450
450
  expect(result).toMatchObject({
451
451
  count: 1,
452
452
  facets: {
453
- 'variants.attributes.number': {
454
- type: 'filter',
453
+ "variants.attributes.number": {
454
+ type: "filter",
455
455
  count: 1,
456
456
  },
457
457
  },
458
458
  results: [
459
459
  {
460
- masterVariant: { sku: 'my-sku' },
460
+ masterVariant: { sku: "my-sku" },
461
461
  },
462
462
  ],
463
- })
464
- })
463
+ });
464
+ });
465
465
 
466
- test('rangeExpr - variants.attributes.number', async () => {
466
+ test("rangeExpr - variants.attributes.number", async () => {
467
467
  const response = await supertest(ctMock.app)
468
- .get('/dummy/product-projections/search')
468
+ .get("/dummy/product-projections/search")
469
469
  .query({
470
470
  facet: [
471
- 'variants.attributes.number:range(* TO 5), (5 TO 25), (25 TO 100)',
471
+ "variants.attributes.number:range(* TO 5), (5 TO 25), (25 TO 100)",
472
472
  ],
473
- })
473
+ });
474
474
 
475
- const result: ProductProjectionPagedSearchResponse = response.body
475
+ const result: ProductProjectionPagedSearchResponse = response.body;
476
476
  expect(result).toMatchObject({
477
477
  count: 1,
478
478
  facets: {
479
- 'variants.attributes.number': {
480
- type: 'range',
481
- dataType: 'number',
479
+ "variants.attributes.number": {
480
+ type: "range",
481
+ dataType: "number",
482
482
  ranges: [
483
483
  {
484
- type: 'double',
484
+ type: "double",
485
485
  from: 0.0,
486
- fromStr: '',
486
+ fromStr: "",
487
487
  to: 5.0,
488
- toStr: '5.0',
488
+ toStr: "5.0",
489
489
  count: 1,
490
490
  // totalCount: 1,
491
491
  total: 4.0,
@@ -494,11 +494,11 @@ describe('Product Projection Search - Facets', () => {
494
494
  mean: 4.0,
495
495
  },
496
496
  {
497
- type: 'double',
497
+ type: "double",
498
498
  from: 5.0,
499
- fromStr: '5.0',
499
+ fromStr: "5.0",
500
500
  to: 25.0,
501
- toStr: '25.0',
501
+ toStr: "25.0",
502
502
  count: 0,
503
503
  // totalCount: 0,
504
504
  total: 0.0,
@@ -507,11 +507,11 @@ describe('Product Projection Search - Facets', () => {
507
507
  mean: 0.0,
508
508
  },
509
509
  {
510
- type: 'double',
510
+ type: "double",
511
511
  from: 25.0,
512
- fromStr: '25.0',
512
+ fromStr: "25.0",
513
513
  to: 100.0,
514
- toStr: '100.0',
514
+ toStr: "100.0",
515
515
  count: 1,
516
516
  // totalCount: 1,
517
517
  total: 50,
@@ -524,9 +524,9 @@ describe('Product Projection Search - Facets', () => {
524
524
  },
525
525
  results: [
526
526
  {
527
- masterVariant: { sku: 'my-sku' },
527
+ masterVariant: { sku: "my-sku" },
528
528
  },
529
529
  ],
530
- })
531
- })
532
- })
530
+ });
531
+ });
532
+ });