@labdigital/commercetools-mock 1.5.0 → 1.6.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.
- package/README.md +5 -4
- package/dist/index.cjs +117 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -7
- package/dist/index.d.ts +30 -7
- package/dist/index.js +117 -17
- package/dist/index.js.map +1 -1
- package/package.json +4 -3
- package/src/constants.ts +2 -2
- package/src/ctMock.ts +176 -176
- package/src/exceptions.ts +10 -10
- package/src/helpers.ts +26 -26
- package/src/index.test.ts +173 -173
- package/src/index.ts +3 -3
- package/src/lib/expandParser.ts +19 -19
- package/src/lib/haversine.test.ts +13 -13
- package/src/lib/haversine.ts +14 -14
- package/src/lib/masking.ts +15 -15
- package/src/lib/parser.ts +2 -2
- package/src/lib/predicateParser.test.ts +204 -204
- package/src/lib/predicateParser.ts +398 -398
- package/src/lib/projectionSearchFilter.test.ts +168 -168
- package/src/lib/projectionSearchFilter.ts +272 -269
- package/src/lib/proxy.ts +8 -8
- package/src/oauth/errors.ts +4 -4
- package/src/oauth/helpers.ts +6 -6
- package/src/oauth/server.ts +103 -101
- package/src/oauth/store.ts +27 -27
- package/src/priceSelector.test.ts +68 -68
- package/src/priceSelector.ts +70 -70
- package/src/product-projection-search.ts +296 -296
- package/src/projectAPI.test.ts +3 -3
- package/src/projectAPI.ts +46 -46
- package/src/repositories/abstract.ts +190 -190
- package/src/repositories/associate-role.ts +10 -7
- package/src/repositories/attribute-group.ts +63 -8
- package/src/repositories/business-unit.ts +10 -7
- package/src/repositories/cart-discount.ts +134 -134
- package/src/repositories/cart.ts +517 -514
- package/src/repositories/category.ts +170 -167
- package/src/repositories/channel.ts +114 -111
- package/src/repositories/custom-object.ts +66 -63
- package/src/repositories/customer-group.ts +72 -69
- package/src/repositories/customer.ts +90 -90
- package/src/repositories/discount-code.ts +171 -168
- package/src/repositories/errors.ts +15 -15
- package/src/repositories/extension.ts +79 -76
- package/src/repositories/helpers.ts +180 -180
- package/src/repositories/index.ts +39 -39
- package/src/repositories/inventory-entry.ts +98 -95
- package/src/repositories/my-order.ts +11 -11
- package/src/repositories/order-edit.ts +29 -29
- package/src/repositories/order.test.ts +191 -191
- package/src/repositories/order.ts +393 -393
- package/src/repositories/payment.ts +155 -155
- package/src/repositories/product-discount.ts +149 -149
- package/src/repositories/product-projection.ts +135 -50
- package/src/repositories/product-selection.ts +31 -31
- package/src/repositories/product-type.ts +156 -156
- package/src/repositories/product.ts +600 -597
- package/src/repositories/project.ts +136 -135
- package/src/repositories/quote-request.ts +19 -19
- package/src/repositories/quote.ts +19 -19
- package/src/repositories/review.ts +24 -24
- package/src/repositories/shipping-method.ts +217 -217
- package/src/repositories/shopping-list.ts +49 -49
- package/src/repositories/staged-quote.ts +20 -20
- package/src/repositories/standalone-price.ts +72 -61
- package/src/repositories/state.ts +84 -84
- package/src/repositories/store.ts +114 -114
- package/src/repositories/subscription.ts +40 -40
- package/src/repositories/tax-category.ts +98 -98
- package/src/repositories/type.ts +157 -157
- package/src/repositories/zone.ts +71 -71
- package/src/server.ts +2 -2
- package/src/services/abstract.ts +173 -173
- package/src/services/attribute-group.ts +16 -0
- package/src/services/cart-discount.ts +8 -8
- package/src/services/cart.test.ts +409 -409
- package/src/services/cart.ts +50 -50
- package/src/services/category.test.ts +25 -25
- package/src/services/category.ts +8 -8
- package/src/services/channel.ts +8 -8
- package/src/services/custom-object.test.ts +184 -184
- package/src/services/custom-object.ts +48 -48
- package/src/services/customer-group.ts +8 -8
- package/src/services/customer.test.ts +151 -151
- package/src/services/customer.ts +27 -27
- package/src/services/discount-code.ts +8 -8
- package/src/services/extension.ts +8 -8
- package/src/services/index.ts +52 -44
- package/src/services/inventory-entry.test.ts +162 -162
- package/src/services/inventory-entry.ts +8 -8
- package/src/services/my-cart.test.ts +78 -78
- package/src/services/my-cart.ts +28 -28
- package/src/services/my-customer.test.ts +44 -44
- package/src/services/my-customer.ts +53 -53
- package/src/services/my-order.ts +20 -20
- package/src/services/my-payment.test.ts +65 -65
- package/src/services/my-payment.ts +8 -8
- package/src/services/order.test.ts +527 -527
- package/src/services/order.ts +31 -31
- package/src/services/payment.test.ts +65 -65
- package/src/services/payment.ts +8 -8
- package/src/services/product-discount.ts +8 -8
- package/src/services/product-projection.test.ts +502 -428
- package/src/services/product-projection.ts +32 -18
- package/src/services/product-type.test.ts +56 -56
- package/src/services/product-type.ts +8 -8
- package/src/services/product.test.ts +510 -510
- package/src/services/product.ts +8 -8
- package/src/services/project.ts +34 -34
- package/src/services/shipping-method.test.ts +81 -81
- package/src/services/shipping-method.ts +12 -12
- package/src/services/shopping-list.ts +8 -8
- package/src/services/standalone-price.test.ts +256 -256
- package/src/services/standalone-price.ts +8 -8
- package/src/services/state.test.ts +42 -42
- package/src/services/state.ts +8 -8
- package/src/services/store.test.ts +57 -57
- package/src/services/store.ts +8 -8
- package/src/services/subscription.ts +8 -8
- package/src/services/tax-category.test.ts +61 -61
- package/src/services/tax-category.ts +8 -8
- package/src/services/type.ts +8 -8
- package/src/services/zone.ts +8 -8
- package/src/storage/abstract.ts +58 -58
- package/src/storage/in-memory.ts +419 -419
- package/src/types.ts +82 -82
|
@@ -1,286 +1,286 @@
|
|
|
1
1
|
import type { StandalonePriceDraft } from '@commercetools/platform-sdk'
|
|
2
2
|
import supertest from 'supertest'
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
afterAll,
|
|
5
|
+
afterEach,
|
|
6
|
+
beforeAll,
|
|
7
|
+
beforeEach,
|
|
8
|
+
describe,
|
|
9
|
+
expect,
|
|
10
|
+
test,
|
|
11
11
|
} from 'vitest'
|
|
12
12
|
import { CommercetoolsMock } from '../index.js'
|
|
13
13
|
|
|
14
14
|
const ctMock = new CommercetoolsMock()
|
|
15
15
|
|
|
16
16
|
describe('Standalone price Query', () => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
17
|
+
beforeAll(async () => {
|
|
18
|
+
const draft: StandalonePriceDraft = {
|
|
19
|
+
value: {
|
|
20
|
+
centAmount: 100,
|
|
21
|
+
currencyCode: 'EUR',
|
|
22
|
+
},
|
|
23
|
+
country: 'DE',
|
|
24
|
+
sku: 'foo',
|
|
25
|
+
active: true,
|
|
26
|
+
channel: {
|
|
27
|
+
typeId: 'channel',
|
|
28
|
+
id: 'bar',
|
|
29
|
+
},
|
|
30
|
+
discounted: {
|
|
31
|
+
value: {
|
|
32
|
+
centAmount: 80,
|
|
33
|
+
currencyCode: 'EUR',
|
|
34
|
+
},
|
|
35
|
+
discount: {
|
|
36
|
+
typeId: 'product-discount',
|
|
37
|
+
id: 'baz',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
const createResponse = await supertest(ctMock.app)
|
|
42
|
+
.post('/dummy/standalone-prices')
|
|
43
|
+
.send(draft)
|
|
44
|
+
expect(createResponse.status).toEqual(201)
|
|
45
|
+
})
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
afterAll(async () => {
|
|
48
|
+
ctMock.clear()
|
|
49
|
+
})
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
test('Get standalone price', async () => {
|
|
52
|
+
const response = await supertest(ctMock.app).get(
|
|
53
|
+
'/dummy/standalone-prices?sku=foo'
|
|
54
|
+
)
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
expect(response.status).toBe(200)
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
58
|
+
expect(response.body.results).toEqual([
|
|
59
|
+
{
|
|
60
|
+
active: true,
|
|
61
|
+
channel: {
|
|
62
|
+
id: 'bar',
|
|
63
|
+
typeId: 'channel',
|
|
64
|
+
},
|
|
65
|
+
country: 'DE',
|
|
66
|
+
createdAt: expect.anything(),
|
|
67
|
+
discounted: {
|
|
68
|
+
discount: {
|
|
69
|
+
id: 'baz',
|
|
70
|
+
typeId: 'product-discount',
|
|
71
|
+
},
|
|
72
|
+
value: {
|
|
73
|
+
centAmount: 80,
|
|
74
|
+
currencyCode: 'EUR',
|
|
75
|
+
fractionDigits: 2,
|
|
76
|
+
type: 'centPrecision',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
id: expect.anything(),
|
|
80
|
+
lastModifiedAt: expect.anything(),
|
|
81
|
+
sku: 'foo',
|
|
82
|
+
value: {
|
|
83
|
+
centAmount: 100,
|
|
84
|
+
currencyCode: 'EUR',
|
|
85
|
+
fractionDigits: 2,
|
|
86
|
+
type: 'centPrecision',
|
|
87
|
+
},
|
|
88
|
+
version: 1,
|
|
89
|
+
},
|
|
90
|
+
])
|
|
91
|
+
})
|
|
92
92
|
})
|
|
93
93
|
|
|
94
94
|
describe('Standalone price Actions', () => {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
95
|
+
let id: string | undefined
|
|
96
|
+
beforeEach(async () => {
|
|
97
|
+
const draft: StandalonePriceDraft = {
|
|
98
|
+
value: {
|
|
99
|
+
centAmount: 100,
|
|
100
|
+
currencyCode: 'EUR',
|
|
101
|
+
},
|
|
102
|
+
country: 'DE',
|
|
103
|
+
sku: 'foo',
|
|
104
|
+
active: true,
|
|
105
|
+
channel: {
|
|
106
|
+
typeId: 'channel',
|
|
107
|
+
id: 'bar',
|
|
108
|
+
},
|
|
109
|
+
}
|
|
110
|
+
const createResponse = await supertest(ctMock.app)
|
|
111
|
+
.post('/dummy/standalone-prices')
|
|
112
|
+
.send(draft)
|
|
113
|
+
expect(createResponse.status).toEqual(201)
|
|
114
|
+
id = createResponse.body.id
|
|
115
|
+
})
|
|
116
116
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
117
|
+
afterEach(async () => {
|
|
118
|
+
ctMock.clear()
|
|
119
|
+
})
|
|
120
120
|
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
121
|
+
test('changeValue', async () => {
|
|
122
|
+
const response = await supertest(ctMock.app)
|
|
123
|
+
.post('/dummy/standalone-prices/' + id)
|
|
124
|
+
.send({
|
|
125
|
+
version: 1,
|
|
126
|
+
actions: [
|
|
127
|
+
{
|
|
128
|
+
action: 'changeValue',
|
|
129
|
+
value: {
|
|
130
|
+
centAmount: 200,
|
|
131
|
+
currencyCode: 'EUR',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
})
|
|
136
136
|
|
|
137
|
-
|
|
137
|
+
expect(response.status).toBe(200)
|
|
138
138
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
139
|
+
expect(response.body).toEqual({
|
|
140
|
+
active: true,
|
|
141
|
+
channel: {
|
|
142
|
+
id: 'bar',
|
|
143
|
+
typeId: 'channel',
|
|
144
|
+
},
|
|
145
|
+
country: 'DE',
|
|
146
|
+
createdAt: expect.anything(),
|
|
147
|
+
id: id,
|
|
148
|
+
lastModifiedAt: expect.anything(),
|
|
149
|
+
sku: 'foo',
|
|
150
|
+
value: {
|
|
151
|
+
centAmount: 200,
|
|
152
|
+
currencyCode: 'EUR',
|
|
153
|
+
fractionDigits: 2,
|
|
154
|
+
type: 'centPrecision',
|
|
155
|
+
},
|
|
156
|
+
version: 2,
|
|
157
|
+
})
|
|
158
|
+
})
|
|
159
159
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
160
|
+
test('setActive', async () => {
|
|
161
|
+
const response = await supertest(ctMock.app)
|
|
162
|
+
.post('/dummy/standalone-prices/' + id)
|
|
163
|
+
.send({
|
|
164
|
+
version: 1,
|
|
165
|
+
actions: [
|
|
166
|
+
{
|
|
167
|
+
action: 'setActive',
|
|
168
|
+
active: false,
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
})
|
|
172
172
|
|
|
173
|
-
|
|
173
|
+
expect(response.status).toBe(200)
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
175
|
+
expect(response.body).toEqual({
|
|
176
|
+
active: false,
|
|
177
|
+
channel: {
|
|
178
|
+
id: 'bar',
|
|
179
|
+
typeId: 'channel',
|
|
180
|
+
},
|
|
181
|
+
country: 'DE',
|
|
182
|
+
createdAt: expect.anything(),
|
|
183
|
+
id: id,
|
|
184
|
+
lastModifiedAt: expect.anything(),
|
|
185
|
+
sku: 'foo',
|
|
186
|
+
value: {
|
|
187
|
+
centAmount: 100,
|
|
188
|
+
currencyCode: 'EUR',
|
|
189
|
+
fractionDigits: 2,
|
|
190
|
+
type: 'centPrecision',
|
|
191
|
+
},
|
|
192
|
+
version: 2,
|
|
193
|
+
})
|
|
194
|
+
})
|
|
195
195
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
196
|
+
test('setDiscounted', async () => {
|
|
197
|
+
const response = await supertest(ctMock.app)
|
|
198
|
+
.post('/dummy/standalone-prices/' + id)
|
|
199
|
+
.send({
|
|
200
|
+
version: 1,
|
|
201
|
+
actions: [
|
|
202
|
+
{
|
|
203
|
+
action: 'setDiscountedPrice',
|
|
204
|
+
discounted: {
|
|
205
|
+
value: {
|
|
206
|
+
centAmount: 80,
|
|
207
|
+
currencyCode: 'EUR',
|
|
208
|
+
},
|
|
209
|
+
discount: {
|
|
210
|
+
typeId: 'product-discount',
|
|
211
|
+
id: 'baz',
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
})
|
|
217
217
|
|
|
218
|
-
|
|
218
|
+
expect(response.status).toBe(200)
|
|
219
219
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
220
|
+
expect(response.body).toEqual({
|
|
221
|
+
active: true,
|
|
222
|
+
channel: {
|
|
223
|
+
id: 'bar',
|
|
224
|
+
typeId: 'channel',
|
|
225
|
+
},
|
|
226
|
+
country: 'DE',
|
|
227
|
+
createdAt: expect.anything(),
|
|
228
|
+
discounted: {
|
|
229
|
+
discount: {
|
|
230
|
+
id: 'baz',
|
|
231
|
+
typeId: 'product-discount',
|
|
232
|
+
},
|
|
233
|
+
value: {
|
|
234
|
+
centAmount: 80,
|
|
235
|
+
currencyCode: 'EUR',
|
|
236
|
+
fractionDigits: 2,
|
|
237
|
+
type: 'centPrecision',
|
|
238
|
+
},
|
|
239
|
+
},
|
|
240
|
+
id: id,
|
|
241
|
+
lastModifiedAt: expect.anything(),
|
|
242
|
+
sku: 'foo',
|
|
243
|
+
value: {
|
|
244
|
+
centAmount: 100,
|
|
245
|
+
currencyCode: 'EUR',
|
|
246
|
+
fractionDigits: 2,
|
|
247
|
+
type: 'centPrecision',
|
|
248
|
+
},
|
|
249
|
+
version: 2,
|
|
250
|
+
})
|
|
251
251
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
252
|
+
const response2 = await supertest(ctMock.app)
|
|
253
|
+
.post('/dummy/standalone-prices/' + id)
|
|
254
|
+
.send({
|
|
255
|
+
version: 2,
|
|
256
|
+
actions: [
|
|
257
|
+
{
|
|
258
|
+
action: 'setDiscountedPrice',
|
|
259
|
+
discounted: null,
|
|
260
|
+
},
|
|
261
|
+
],
|
|
262
|
+
})
|
|
263
263
|
|
|
264
|
-
|
|
264
|
+
expect(response2.status).toBe(200)
|
|
265
265
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
266
|
+
expect(response2.body).toEqual({
|
|
267
|
+
active: true,
|
|
268
|
+
channel: {
|
|
269
|
+
id: 'bar',
|
|
270
|
+
typeId: 'channel',
|
|
271
|
+
},
|
|
272
|
+
country: 'DE',
|
|
273
|
+
createdAt: expect.anything(),
|
|
274
|
+
id: id,
|
|
275
|
+
lastModifiedAt: expect.anything(),
|
|
276
|
+
sku: 'foo',
|
|
277
|
+
value: {
|
|
278
|
+
centAmount: 100,
|
|
279
|
+
currencyCode: 'EUR',
|
|
280
|
+
fractionDigits: 2,
|
|
281
|
+
type: 'centPrecision',
|
|
282
|
+
},
|
|
283
|
+
version: 3,
|
|
284
|
+
})
|
|
285
|
+
})
|
|
286
286
|
})
|
|
@@ -3,14 +3,14 @@ import { StandAlonePriceRepository } from '../repositories/standalone-price.js'
|
|
|
3
3
|
import AbstractService from './abstract.js'
|
|
4
4
|
|
|
5
5
|
export class StandAlonePriceService extends AbstractService {
|
|
6
|
-
|
|
6
|
+
public repository: StandAlonePriceRepository
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
constructor(parent: Router, repository: StandAlonePriceRepository) {
|
|
9
|
+
super(parent)
|
|
10
|
+
this.repository = repository
|
|
11
|
+
}
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
getBasePath() {
|
|
14
|
+
return 'standalone-prices'
|
|
15
|
+
}
|
|
16
16
|
}
|
|
@@ -6,46 +6,46 @@ import { CommercetoolsMock } from '../index.js'
|
|
|
6
6
|
const ctMock = new CommercetoolsMock()
|
|
7
7
|
|
|
8
8
|
describe('State', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
9
|
+
test('Create state', async () => {
|
|
10
|
+
const draft: StateDraft = {
|
|
11
|
+
key: 'foo',
|
|
12
|
+
type: 'PaymentState',
|
|
13
|
+
}
|
|
14
|
+
const response = await supertest(ctMock.app)
|
|
15
|
+
.post('/dummy/states')
|
|
16
|
+
.send(draft)
|
|
17
|
+
|
|
18
|
+
expect(response.status).toBe(201)
|
|
19
|
+
|
|
20
|
+
expect(response.body).toEqual({
|
|
21
|
+
builtIn: false,
|
|
22
|
+
createdAt: expect.anything(),
|
|
23
|
+
id: expect.anything(),
|
|
24
|
+
initial: false,
|
|
25
|
+
key: 'foo',
|
|
26
|
+
lastModifiedAt: expect.anything(),
|
|
27
|
+
transitions: [],
|
|
28
|
+
type: 'PaymentState',
|
|
29
|
+
version: 1,
|
|
30
|
+
})
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('Get state', async () => {
|
|
34
|
+
const draft: StateDraft = {
|
|
35
|
+
key: 'foo',
|
|
36
|
+
type: 'PaymentState',
|
|
37
|
+
}
|
|
38
|
+
const createResponse = await supertest(ctMock.app)
|
|
39
|
+
.post('/dummy/states')
|
|
40
|
+
.send(draft)
|
|
41
|
+
|
|
42
|
+
expect(createResponse.status).toBe(201)
|
|
43
|
+
|
|
44
|
+
const response = await supertest(ctMock.app).get(
|
|
45
|
+
`/dummy/states/${createResponse.body.id}`
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
expect(response.status).toBe(200)
|
|
49
|
+
expect(response.body).toEqual(createResponse.body)
|
|
50
|
+
})
|
|
51
51
|
})
|