@labdigital/commercetools-mock 2.17.1 → 2.18.1

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 (180) hide show
  1. package/dist/index.cjs +4351 -4099
  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 +4351 -4099
  6. package/dist/index.js.map +1 -1
  7. package/package.json +47 -47
  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/schemas/update-request.ts +12 -0
  98. package/src/server.ts +9 -9
  99. package/src/services/abstract.ts +85 -72
  100. package/src/services/associate-roles.test.ts +27 -27
  101. package/src/services/associate-roles.ts +7 -7
  102. package/src/services/attribute-group.ts +7 -7
  103. package/src/services/business-units.test.ts +28 -28
  104. package/src/services/business-units.ts +7 -7
  105. package/src/services/cart-discount.test.ts +199 -199
  106. package/src/services/cart-discount.ts +7 -7
  107. package/src/services/cart.test.ts +261 -261
  108. package/src/services/cart.ts +22 -21
  109. package/src/services/category.test.ts +121 -121
  110. package/src/services/category.ts +7 -7
  111. package/src/services/channel.ts +7 -7
  112. package/src/services/custom-object.test.ts +130 -130
  113. package/src/services/custom-object.ts +34 -31
  114. package/src/services/customer-group.ts +7 -7
  115. package/src/services/customer.test.ts +205 -205
  116. package/src/services/customer.ts +23 -36
  117. package/src/services/discount-code.ts +7 -7
  118. package/src/services/extension.ts +7 -7
  119. package/src/services/index.ts +85 -81
  120. package/src/services/inventory-entry.test.ts +106 -106
  121. package/src/services/inventory-entry.ts +7 -7
  122. package/src/services/my-cart.test.ts +56 -56
  123. package/src/services/my-cart.ts +20 -20
  124. package/src/services/my-customer.test.ts +155 -104
  125. package/src/services/my-customer.ts +66 -75
  126. package/src/services/my-order.ts +16 -16
  127. package/src/services/my-payment.test.ts +40 -40
  128. package/src/services/my-payment.ts +7 -7
  129. package/src/services/my-shopping-list.ts +7 -7
  130. package/src/services/order.test.ts +243 -243
  131. package/src/services/order.ts +23 -18
  132. package/src/services/payment.test.ts +40 -40
  133. package/src/services/payment.ts +7 -7
  134. package/src/services/product-discount.ts +7 -7
  135. package/src/services/product-projection.test.ts +190 -190
  136. package/src/services/product-projection.ts +34 -32
  137. package/src/services/product-selection.test.ts +19 -19
  138. package/src/services/product-selection.ts +7 -7
  139. package/src/services/product-type.test.ts +38 -38
  140. package/src/services/product-type.ts +7 -7
  141. package/src/services/product.test.ts +658 -656
  142. package/src/services/product.ts +7 -7
  143. package/src/services/project.test.ts +29 -24
  144. package/src/services/project.ts +22 -17
  145. package/src/services/reviews.ts +7 -7
  146. package/src/services/shipping-method.test.ts +78 -78
  147. package/src/services/shipping-method.ts +16 -16
  148. package/src/services/shopping-list.test.ts +170 -170
  149. package/src/services/shopping-list.ts +7 -7
  150. package/src/services/standalone-price.test.ts +112 -112
  151. package/src/services/standalone-price.ts +7 -7
  152. package/src/services/state.test.ts +30 -30
  153. package/src/services/state.ts +7 -7
  154. package/src/services/store.test.ts +40 -40
  155. package/src/services/store.ts +7 -7
  156. package/src/services/subscription.ts +7 -7
  157. package/src/services/tax-category.test.ts +43 -43
  158. package/src/services/tax-category.ts +7 -7
  159. package/src/services/type.ts +7 -7
  160. package/src/services/zone.ts +7 -7
  161. package/src/shippingCalculator.test.ts +43 -43
  162. package/src/shippingCalculator.ts +23 -23
  163. package/src/storage/abstract.ts +36 -34
  164. package/src/storage/in-memory.ts +237 -233
  165. package/src/storage/index.ts +2 -2
  166. package/src/types.ts +91 -91
  167. package/src/validate.ts +18 -0
  168. package/src/repositories/cart-discount.ts +0 -219
  169. package/src/repositories/cart.ts +0 -659
  170. package/src/repositories/category.ts +0 -256
  171. package/src/repositories/customer.ts +0 -228
  172. package/src/repositories/discount-code.ts +0 -181
  173. package/src/repositories/inventory-entry.ts +0 -109
  174. package/src/repositories/order.ts +0 -514
  175. package/src/repositories/payment.ts +0 -342
  176. package/src/repositories/product.ts +0 -1106
  177. package/src/repositories/shipping-method.ts +0 -312
  178. package/src/repositories/shopping-list.ts +0 -392
  179. package/src/repositories/tax-category.ts +0 -111
  180. package/src/repositories/type.ts +0 -172
@@ -1,16 +1,16 @@
1
- import { Router } from 'express'
2
- import { ProductRepository } from '../repositories/product.js'
3
- import AbstractService from './abstract.js'
1
+ import { Router } from "express";
2
+ import { ProductRepository } from "../repositories/product";
3
+ import AbstractService from "./abstract";
4
4
 
5
5
  export class ProductService extends AbstractService {
6
- public repository: ProductRepository
6
+ public repository: ProductRepository;
7
7
 
8
8
  constructor(parent: Router, repository: ProductRepository) {
9
- super(parent)
10
- this.repository = repository
9
+ super(parent);
10
+ this.repository = repository;
11
11
  }
12
12
 
13
13
  getBasePath() {
14
- return 'products'
14
+ return "products";
15
15
  }
16
16
  }
@@ -1,27 +1,27 @@
1
- import type { Project } from '@commercetools/platform-sdk'
2
- import supertest from 'supertest'
3
- import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest'
4
- import { CommercetoolsMock } from '../index.js'
1
+ import type { Project } from "@commercetools/platform-sdk";
2
+ import supertest from "supertest";
3
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from "vitest";
4
+ import { CommercetoolsMock } from "../index";
5
5
 
6
- const ctMock = new CommercetoolsMock()
6
+ const ctMock = new CommercetoolsMock();
7
7
 
8
- describe('Project', () => {
8
+ describe("Project", () => {
9
9
  beforeAll(() => {
10
- ctMock.start()
11
- })
10
+ ctMock.start();
11
+ });
12
12
 
13
13
  afterEach(() => {
14
- ctMock.clear()
15
- })
14
+ ctMock.clear();
15
+ });
16
16
 
17
17
  afterAll(() => {
18
- ctMock.stop()
19
- })
18
+ ctMock.stop();
19
+ });
20
20
 
21
- test('Get project by key', async () => {
22
- const response = await supertest(ctMock.app).get('/dummy/')
21
+ test("Get project by key", async () => {
22
+ const response = await supertest(ctMock.app).get("/dummy/");
23
23
 
24
- expect(response.status).toBe(200)
24
+ expect(response.status).toBe(200);
25
25
  expect(response.body).toEqual({
26
26
  version: 1,
27
27
  carts: {
@@ -29,24 +29,29 @@ describe('Project', () => {
29
29
  deleteDaysAfterLastModification: 90,
30
30
  },
31
31
  countries: [],
32
- createdAt: '2018-10-04T11:32:12.603Z',
32
+ createdAt: "2018-10-04T11:32:12.603Z",
33
33
  currencies: [],
34
- key: 'dummy',
34
+ key: "dummy",
35
35
  languages: [],
36
36
  messages: {
37
37
  deleteDaysAfterCreation: 15,
38
38
  enabled: false,
39
39
  },
40
- name: '',
40
+ name: "",
41
41
  searchIndexing: {
42
42
  orders: {
43
- status: 'Deactivated',
43
+ status: "Deactivated",
44
44
  },
45
45
  products: {
46
- status: 'Deactivated',
46
+ status: "Deactivated",
47
47
  },
48
48
  },
49
- trialUntil: '2018-12',
50
- } as Project)
51
- })
52
- })
49
+ trialUntil: "2018-12",
50
+ } as Project);
51
+ });
52
+
53
+ test("Post empty update ", async () => {
54
+ const response = await supertest(ctMock.app).post("/dummy/");
55
+ expect(response.statusCode).toBe(400);
56
+ });
57
+ });
@@ -1,41 +1,46 @@
1
- import type { Update } from '@commercetools/platform-sdk'
2
- import { Request, Response, Router } from 'express'
3
- import { getRepositoryContext } from '../repositories/helpers.js'
4
- import { ProjectRepository } from '../repositories/project.js'
1
+ import { Update } from "@commercetools/platform-sdk";
2
+ import { Request, Response, Router } from "express";
3
+ import { updateRequestSchema } from "~src/schemas/update-request";
4
+ import { validateData } from "~src/validate";
5
+ import { getRepositoryContext } from "../repositories/helpers";
6
+ import { ProjectRepository } from "../repositories/project";
5
7
 
6
8
  export class ProjectService {
7
- public repository: ProjectRepository
9
+ public repository: ProjectRepository;
8
10
 
9
11
  constructor(parent: Router, repository: ProjectRepository) {
10
- this.repository = repository
11
- this.registerRoutes(parent)
12
+ this.repository = repository;
13
+ this.registerRoutes(parent);
12
14
  }
13
15
 
14
16
  registerRoutes(parent: Router) {
15
- parent.get('', this.get.bind(this))
16
- parent.post('', this.post.bind(this))
17
+ parent.get("", this.get.bind(this));
18
+ parent.post("", this.post.bind(this));
17
19
  }
18
20
 
19
21
  get(request: Request, response: Response) {
20
- const project = this.repository.get(getRepositoryContext(request))
21
- return response.status(200).send(project)
22
+ const project = this.repository.get(getRepositoryContext(request));
23
+ return response.status(200).send(project);
22
24
  }
23
25
 
24
26
  post(request: Request, response: Response) {
25
- const updateRequest: Update = request.body
26
- const project = this.repository.get(getRepositoryContext(request))
27
+ const updateRequest = validateData<Update>(
28
+ request.body,
29
+ updateRequestSchema,
30
+ );
31
+ const project = this.repository.get(getRepositoryContext(request));
27
32
 
28
33
  if (!project) {
29
- return response.status(404).send({})
34
+ return response.status(404).send({});
30
35
  }
31
36
 
32
37
  const updatedResource = this.repository.processUpdateActions(
33
38
  getRepositoryContext(request),
34
39
  project,
35
40
  updateRequest.version,
36
- updateRequest.actions
37
- )
41
+ updateRequest.actions,
42
+ );
38
43
 
39
- return response.status(200).send(updatedResource)
44
+ return response.status(200).send(updatedResource);
40
45
  }
41
46
  }
@@ -1,16 +1,16 @@
1
- import { Router } from 'express'
2
- import AbstractService from './abstract.js'
3
- import { ReviewRepository } from '../repositories/review.js'
1
+ import { Router } from "express";
2
+ import { ReviewRepository } from "../repositories/review";
3
+ import AbstractService from "./abstract";
4
4
 
5
5
  export class ReviewService extends AbstractService {
6
- public repository: ReviewRepository
6
+ public repository: ReviewRepository;
7
7
 
8
8
  constructor(parent: Router, repository: ReviewRepository) {
9
- super(parent)
10
- this.repository = repository
9
+ super(parent);
10
+ this.repository = repository;
11
11
  }
12
12
 
13
13
  getBasePath() {
14
- return 'reviews'
14
+ return "reviews";
15
15
  }
16
16
  }
@@ -4,190 +4,190 @@ import type {
4
4
  ShippingMethodDraft,
5
5
  TaxCategoryDraft,
6
6
  ZoneDraft,
7
- } from '@commercetools/platform-sdk'
8
- import supertest from 'supertest'
9
- import { afterEach, beforeEach, describe, expect, test } from 'vitest'
10
- import { CommercetoolsMock } from '../index.js'
11
- import { isType } from '../types.js'
7
+ } from "@commercetools/platform-sdk";
8
+ import supertest from "supertest";
9
+ import { afterEach, beforeEach, describe, expect, test } from "vitest";
10
+ import { CommercetoolsMock } from "../index";
11
+ import { isType } from "../types";
12
12
 
13
- const ctMock = new CommercetoolsMock()
13
+ const ctMock = new CommercetoolsMock();
14
14
 
15
- describe('Shipping method', () => {
15
+ describe("Shipping method", () => {
16
16
  beforeEach(async () => {
17
17
  await supertest(ctMock.app)
18
- .post('/dummy/tax-categories')
18
+ .post("/dummy/tax-categories")
19
19
  .send(
20
20
  isType<TaxCategoryDraft>({
21
- name: 'foo',
22
- key: 'standard',
21
+ name: "foo",
22
+ key: "standard",
23
23
  rates: [],
24
- })
24
+ }),
25
25
  )
26
26
  .then((res) => {
27
- expect(res.status).toEqual(201)
28
- })
27
+ expect(res.status).toEqual(201);
28
+ });
29
29
 
30
30
  await supertest(ctMock.app)
31
- .post('/dummy/zones')
31
+ .post("/dummy/zones")
32
32
  .send(
33
33
  isType<ZoneDraft>({
34
- name: 'The Netherlands',
35
- key: 'NL',
34
+ name: "The Netherlands",
35
+ key: "NL",
36
36
  locations: [
37
37
  {
38
- country: 'NL',
38
+ country: "NL",
39
39
  },
40
40
  ],
41
- })
41
+ }),
42
42
  )
43
43
  .then((res) => {
44
- expect(res.status).toEqual(201)
45
- })
46
- })
44
+ expect(res.status).toEqual(201);
45
+ });
46
+ });
47
47
 
48
48
  afterEach(async () => {
49
- ctMock.clear()
50
- })
49
+ ctMock.clear();
50
+ });
51
51
 
52
- test('Create shipping method', async () => {
52
+ test("Create shipping method", async () => {
53
53
  const draft: ShippingMethodDraft = {
54
- name: 'foo',
55
- taxCategory: { typeId: 'tax-category', key: 'standard' },
54
+ name: "foo",
55
+ taxCategory: { typeId: "tax-category", key: "standard" },
56
56
  isDefault: true,
57
57
  zoneRates: [],
58
- }
58
+ };
59
59
  const response = await supertest(ctMock.app)
60
- .post('/dummy/shipping-methods')
61
- .send(draft)
60
+ .post("/dummy/shipping-methods")
61
+ .send(draft);
62
62
 
63
- expect(response.status).toBe(201)
63
+ expect(response.status).toBe(201);
64
64
 
65
65
  expect(response.body).toEqual({
66
66
  createdAt: expect.anything(),
67
67
  id: expect.anything(),
68
68
  isDefault: true,
69
69
  lastModifiedAt: expect.anything(),
70
- name: 'foo',
70
+ name: "foo",
71
71
  taxCategory: {
72
72
  id: expect.anything(),
73
- typeId: 'tax-category',
73
+ typeId: "tax-category",
74
74
  },
75
75
  version: 1,
76
76
  zoneRates: [],
77
- })
78
- })
77
+ });
78
+ });
79
79
 
80
- test('Get shipping method', async () => {
80
+ test("Get shipping method", async () => {
81
81
  const draft: ShippingMethodDraft = {
82
- name: 'foo',
83
- taxCategory: { typeId: 'tax-category', key: 'standard' },
82
+ name: "foo",
83
+ taxCategory: { typeId: "tax-category", key: "standard" },
84
84
  isDefault: true,
85
85
  zoneRates: [],
86
- }
86
+ };
87
87
  const createResponse = await supertest(ctMock.app)
88
- .post('/dummy/shipping-methods')
89
- .send(draft)
88
+ .post("/dummy/shipping-methods")
89
+ .send(draft);
90
90
 
91
- expect(createResponse.status).toBe(201)
91
+ expect(createResponse.status).toBe(201);
92
92
 
93
93
  const response = await supertest(ctMock.app).get(
94
- `/dummy/shipping-methods/${createResponse.body.id}`
95
- )
94
+ `/dummy/shipping-methods/${createResponse.body.id}`,
95
+ );
96
96
 
97
- expect(response.status).toBe(200)
98
- expect(response.body).toEqual(createResponse.body)
99
- })
97
+ expect(response.status).toBe(200);
98
+ expect(response.body).toEqual(createResponse.body);
99
+ });
100
100
 
101
- test('Get shipping methods matching cart', async () => {
101
+ test("Get shipping methods matching cart", async () => {
102
102
  const cart = await supertest(ctMock.app)
103
- .post('/dummy/carts')
103
+ .post("/dummy/carts")
104
104
  .send(
105
105
  isType<CartDraft>({
106
- currency: 'EUR',
106
+ currency: "EUR",
107
107
  shippingAddress: {
108
- country: 'NL',
108
+ country: "NL",
109
109
  },
110
- })
110
+ }),
111
111
  )
112
- .then((res) => res.body as Cart)
112
+ .then((res) => res.body as Cart);
113
113
 
114
114
  await supertest(ctMock.app)
115
- .post('/dummy/shipping-methods')
115
+ .post("/dummy/shipping-methods")
116
116
  .send(
117
117
  isType<ShippingMethodDraft>({
118
- name: 'NL',
119
- taxCategory: { typeId: 'tax-category', key: 'standard' },
118
+ name: "NL",
119
+ taxCategory: { typeId: "tax-category", key: "standard" },
120
120
  isDefault: true,
121
121
  zoneRates: [
122
122
  {
123
123
  zone: {
124
- typeId: 'zone',
125
- key: 'NL',
124
+ typeId: "zone",
125
+ key: "NL",
126
126
  },
127
127
  shippingRates: [
128
128
  {
129
129
  price: {
130
- currencyCode: 'EUR',
130
+ currencyCode: "EUR",
131
131
  centAmount: 495,
132
132
  },
133
133
  },
134
134
  ],
135
135
  },
136
136
  ],
137
- })
137
+ }),
138
138
  )
139
139
  .then((res) => {
140
- expect(res.status).toEqual(201)
141
- })
140
+ expect(res.status).toEqual(201);
141
+ });
142
142
 
143
143
  await supertest(ctMock.app)
144
- .post('/dummy/shipping-methods')
144
+ .post("/dummy/shipping-methods")
145
145
  .send(
146
146
  isType<ShippingMethodDraft>({
147
- name: 'NL/GBP',
148
- taxCategory: { typeId: 'tax-category', key: 'standard' },
147
+ name: "NL/GBP",
148
+ taxCategory: { typeId: "tax-category", key: "standard" },
149
149
  isDefault: true,
150
150
  zoneRates: [
151
151
  {
152
152
  zone: {
153
- typeId: 'zone',
154
- key: 'NL',
153
+ typeId: "zone",
154
+ key: "NL",
155
155
  },
156
156
  shippingRates: [
157
157
  {
158
158
  price: {
159
- currencyCode: 'GBP',
159
+ currencyCode: "GBP",
160
160
  centAmount: 495,
161
161
  },
162
162
  },
163
163
  ],
164
164
  },
165
165
  ],
166
- })
166
+ }),
167
167
  )
168
168
  .then((res) => {
169
- expect(res.status).toEqual(201)
170
- })
169
+ expect(res.status).toEqual(201);
170
+ });
171
171
 
172
172
  const response = await supertest(ctMock.app).get(
173
- `/dummy/shipping-methods/matching-cart?cartId=${cart.id}`
174
- )
173
+ `/dummy/shipping-methods/matching-cart?cartId=${cart.id}`,
174
+ );
175
175
 
176
- expect(response.status, JSON.stringify(response.body)).toBe(200)
176
+ expect(response.status, JSON.stringify(response.body)).toBe(200);
177
177
  expect(response.body).toMatchObject({
178
178
  count: 1,
179
179
  limit: 20,
180
180
  offset: 0,
181
181
  results: [
182
182
  {
183
- name: 'NL',
183
+ name: "NL",
184
184
  zoneRates: [
185
185
  {
186
186
  shippingRates: [
187
187
  {
188
188
  isMatching: true,
189
189
  price: {
190
- currencyCode: 'EUR',
190
+ currencyCode: "EUR",
191
191
  centAmount: 495,
192
192
  },
193
193
  },
@@ -197,6 +197,6 @@ describe('Shipping method', () => {
197
197
  },
198
198
  ],
199
199
  total: 1,
200
- })
201
- })
202
- })
200
+ });
201
+ });
202
+ });
@@ -1,38 +1,38 @@
1
- import { Request, Response, Router } from 'express'
2
- import { ShippingMethodRepository } from '../repositories/shipping-method.js'
3
- import AbstractService from './abstract.js'
4
- import { getRepositoryContext } from '../repositories/helpers.js'
5
- import { queryParamsValue } from '../helpers.js'
1
+ import { Request, Response, Router } from "express";
2
+ import { queryParamsValue } from "../helpers";
3
+ import { getRepositoryContext } from "../repositories/helpers";
4
+ import { ShippingMethodRepository } from "../repositories/shipping-method";
5
+ import AbstractService from "./abstract";
6
6
 
7
7
  export class ShippingMethodService extends AbstractService {
8
- public repository: ShippingMethodRepository
8
+ public repository: ShippingMethodRepository;
9
9
 
10
10
  constructor(parent: Router, repository: ShippingMethodRepository) {
11
- super(parent)
12
- this.repository = repository
13
- this.registerRoutes(parent)
11
+ super(parent);
12
+ this.repository = repository;
13
+ this.registerRoutes(parent);
14
14
  }
15
15
 
16
16
  getBasePath() {
17
- return 'shipping-methods'
17
+ return "shipping-methods";
18
18
  }
19
19
 
20
20
  extraRoutes(parent: Router) {
21
- parent.get('/matching-cart', this.matchingCart.bind(this))
21
+ parent.get("/matching-cart", this.matchingCart.bind(this));
22
22
  }
23
23
 
24
24
  matchingCart(request: Request, response: Response) {
25
- const cartId = queryParamsValue(request.query.cartId)
25
+ const cartId = queryParamsValue(request.query.cartId);
26
26
  if (!cartId) {
27
- return response.status(400).send()
27
+ return response.status(400).send();
28
28
  }
29
29
  const result = this.repository.matchingCart(
30
30
  getRepositoryContext(request),
31
31
  cartId,
32
32
  {
33
33
  expand: this._parseParam(request.query.expand),
34
- }
35
- )
36
- return response.status(200).send(result)
34
+ },
35
+ );
36
+ return response.status(200).send(result);
37
37
  }
38
38
  }