@labdigital/commercetools-mock 1.2.0 → 1.3.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/dist/index.d.mts +602 -0
- package/dist/index.d.ts +43 -26
- package/dist/index.global.js +5827 -5596
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +344 -167
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +344 -171
- package/dist/index.mjs.map +1 -1
- package/package.json +33 -39
- package/src/index.test.ts +2 -1
- package/src/lib/haversine.test.ts +1 -0
- package/src/lib/predicateParser.test.ts +2 -1
- package/src/lib/predicateParser.ts +2 -2
- package/src/lib/projectionSearchFilter.test.ts +2 -1
- package/src/lib/projectionSearchFilter.ts +4 -4
- package/src/oauth/server.ts +3 -4
- package/src/priceSelector.test.ts +2 -1
- package/src/priceSelector.ts +2 -2
- package/src/product-projection-search.ts +8 -8
- package/src/projectAPI.test.ts +1 -0
- package/src/repositories/abstract.ts +1 -1
- package/src/repositories/associate-role.ts +11 -0
- package/src/repositories/attribute-group.ts +11 -0
- package/src/repositories/business-unit.ts +11 -0
- package/src/repositories/cart-discount.ts +11 -4
- package/src/repositories/cart.ts +90 -13
- package/src/repositories/category.ts +3 -3
- package/src/repositories/channel.ts +3 -3
- package/src/repositories/custom-object.ts +3 -3
- package/src/repositories/customer-group.ts +3 -3
- package/src/repositories/customer.ts +4 -3
- package/src/repositories/discount-code.ts +3 -3
- package/src/repositories/errors.ts +1 -1
- package/src/repositories/extension.ts +3 -3
- package/src/repositories/helpers.ts +49 -6
- package/src/repositories/index.ts +6 -0
- package/src/repositories/inventory-entry.ts +4 -4
- package/src/repositories/my-order.ts +2 -2
- package/src/repositories/order-edit.ts +2 -2
- package/src/repositories/order.test.ts +10 -39
- package/src/repositories/order.ts +31 -16
- package/src/repositories/payment.ts +8 -7
- package/src/repositories/product-discount.ts +2 -2
- package/src/repositories/product-projection.ts +5 -5
- package/src/repositories/product-selection.ts +3 -2
- package/src/repositories/product-type.ts +2 -2
- package/src/repositories/product.ts +4 -9
- package/src/repositories/project.ts +2 -2
- package/src/repositories/quote-request.ts +2 -2
- package/src/repositories/quote.ts +2 -2
- package/src/repositories/review.ts +2 -2
- package/src/repositories/shipping-method.ts +2 -2
- package/src/repositories/shopping-list.ts +19 -13
- package/src/repositories/staged-quote.ts +2 -2
- package/src/repositories/standalone-price.ts +3 -3
- package/src/repositories/state.ts +2 -2
- package/src/repositories/store.ts +3 -2
- package/src/repositories/subscription.ts +1 -1
- package/src/repositories/tax-category.ts +2 -2
- package/src/repositories/type.ts +2 -2
- package/src/repositories/zone.ts +2 -2
- package/src/services/abstract.ts +2 -2
- package/src/services/cart.test.ts +2 -1
- package/src/services/cart.ts +4 -4
- package/src/services/category.test.ts +2 -1
- package/src/services/custom-object.test.ts +2 -1
- package/src/services/custom-object.ts +3 -3
- package/src/services/customer.test.ts +1 -0
- package/src/services/inventory-entry.test.ts +2 -1
- package/src/services/my-cart.test.ts +7 -3
- package/src/services/my-customer.test.ts +4 -2
- package/src/services/my-payment.test.ts +2 -1
- package/src/services/order.test.ts +2 -1
- package/src/services/payment.test.ts +2 -1
- package/src/services/product-projection.test.ts +3 -2
- package/src/services/product-type.test.ts +2 -1
- package/src/services/product.test.ts +2 -1
- package/src/services/project.ts +1 -1
- package/src/services/shipping-method.test.ts +2 -1
- package/src/services/standalone-price.test.ts +255 -244
- package/src/services/state.test.ts +2 -1
- package/src/services/store.test.ts +6 -1
- package/src/services/tax-category.test.ts +2 -1
- package/src/storage/abstract.ts +1 -1
- package/src/storage/in-memory.ts +7 -1
- package/src/types.ts +7 -1
|
@@ -1,275 +1,286 @@
|
|
|
1
|
-
import { StandalonePriceDraft } from '@commercetools/platform-sdk'
|
|
1
|
+
import type { StandalonePriceDraft } from '@commercetools/platform-sdk'
|
|
2
2
|
import supertest from 'supertest'
|
|
3
|
+
import {
|
|
4
|
+
afterAll,
|
|
5
|
+
afterEach,
|
|
6
|
+
beforeAll,
|
|
7
|
+
beforeEach,
|
|
8
|
+
describe,
|
|
9
|
+
expect,
|
|
10
|
+
test,
|
|
11
|
+
} from 'vitest'
|
|
3
12
|
import { CommercetoolsMock } from '../index'
|
|
4
13
|
|
|
5
14
|
const ctMock = new CommercetoolsMock()
|
|
6
15
|
|
|
7
16
|
describe('Standalone price Query', () => {
|
|
8
|
-
|
|
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
|
-
|
|
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
|
+
})
|
|
37
46
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
afterAll(async () => {
|
|
48
|
+
ctMock.clear()
|
|
49
|
+
})
|
|
41
50
|
|
|
42
|
-
|
|
43
|
-
|
|
51
|
+
test('Get standalone price', async () => {
|
|
52
|
+
const response = await supertest(ctMock.app).get(
|
|
53
|
+
'/dummy/standalone-prices?sku=foo'
|
|
54
|
+
)
|
|
44
55
|
|
|
45
|
-
|
|
56
|
+
expect(response.status).toBe(200)
|
|
46
57
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
+
})
|
|
81
92
|
})
|
|
82
93
|
|
|
83
94
|
describe('Standalone price Actions', () => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
})
|
|
105
116
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
test('changeValue', async () => {
|
|
111
|
-
const response = await supertest(ctMock.app)
|
|
112
|
-
.post('/dummy/standalone-prices/' + id)
|
|
113
|
-
.send({
|
|
114
|
-
version: 1,
|
|
115
|
-
actions: [
|
|
116
|
-
{
|
|
117
|
-
action: 'changeValue',
|
|
118
|
-
value: {
|
|
119
|
-
centAmount: 200,
|
|
120
|
-
currencyCode: 'EUR',
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
],
|
|
124
|
-
})
|
|
125
|
-
|
|
126
|
-
expect(response.status).toBe(200)
|
|
117
|
+
afterEach(async () => {
|
|
118
|
+
ctMock.clear()
|
|
119
|
+
})
|
|
127
120
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
id: id,
|
|
137
|
-
lastModifiedAt: expect.anything(),
|
|
138
|
-
sku: 'foo',
|
|
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',
|
|
139
129
|
value: {
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
fractionDigits: 2,
|
|
143
|
-
type: 'centPrecision',
|
|
130
|
+
centAmount: 200,
|
|
131
|
+
currencyCode: 'EUR',
|
|
144
132
|
},
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
})
|
|
148
136
|
|
|
149
|
-
|
|
150
|
-
const response = await supertest(ctMock.app)
|
|
151
|
-
.post('/dummy/standalone-prices/' + id)
|
|
152
|
-
.send({
|
|
153
|
-
version: 1,
|
|
154
|
-
actions: [
|
|
155
|
-
{
|
|
156
|
-
action: 'setActive',
|
|
157
|
-
active: false,
|
|
158
|
-
},
|
|
159
|
-
],
|
|
160
|
-
})
|
|
137
|
+
expect(response.status).toBe(200)
|
|
161
138
|
|
|
162
|
-
|
|
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
|
+
})
|
|
163
159
|
|
|
164
|
-
|
|
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',
|
|
165
168
|
active: false,
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
},
|
|
170
|
-
country: 'DE',
|
|
171
|
-
createdAt: expect.anything(),
|
|
172
|
-
id: id,
|
|
173
|
-
lastModifiedAt: expect.anything(),
|
|
174
|
-
sku: 'foo',
|
|
175
|
-
value: {
|
|
176
|
-
centAmount: 100,
|
|
177
|
-
currencyCode: 'EUR',
|
|
178
|
-
fractionDigits: 2,
|
|
179
|
-
type: 'centPrecision',
|
|
180
|
-
},
|
|
181
|
-
version: 2,
|
|
182
|
-
})
|
|
183
|
-
})
|
|
169
|
+
},
|
|
170
|
+
],
|
|
171
|
+
})
|
|
184
172
|
|
|
185
|
-
|
|
186
|
-
const response = await supertest(ctMock.app)
|
|
187
|
-
.post('/dummy/standalone-prices/' + id)
|
|
188
|
-
.send({
|
|
189
|
-
version: 1,
|
|
190
|
-
actions: [
|
|
191
|
-
{
|
|
192
|
-
action: 'setDiscountedPrice',
|
|
193
|
-
discounted: {
|
|
194
|
-
value: {
|
|
195
|
-
centAmount: 80,
|
|
196
|
-
currencyCode: 'EUR',
|
|
197
|
-
},
|
|
198
|
-
discount: {
|
|
199
|
-
typeId: 'product-discount',
|
|
200
|
-
id: 'baz',
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
|
-
},
|
|
204
|
-
],
|
|
205
|
-
})
|
|
173
|
+
expect(response.status).toBe(200)
|
|
206
174
|
|
|
207
|
-
|
|
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
|
+
})
|
|
208
195
|
|
|
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',
|
|
217
204
|
discounted: {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
typeId: 'product-discount',
|
|
221
|
-
},
|
|
222
|
-
value: {
|
|
223
|
-
centAmount: 80,
|
|
224
|
-
currencyCode: 'EUR',
|
|
225
|
-
fractionDigits: 2,
|
|
226
|
-
type: 'centPrecision',
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
id: id,
|
|
230
|
-
lastModifiedAt: expect.anything(),
|
|
231
|
-
sku: 'foo',
|
|
232
|
-
value: {
|
|
233
|
-
centAmount: 100,
|
|
205
|
+
value: {
|
|
206
|
+
centAmount: 80,
|
|
234
207
|
currencyCode: 'EUR',
|
|
235
|
-
|
|
236
|
-
|
|
208
|
+
},
|
|
209
|
+
discount: {
|
|
210
|
+
typeId: 'product-discount',
|
|
211
|
+
id: 'baz',
|
|
212
|
+
},
|
|
237
213
|
},
|
|
238
|
-
|
|
239
|
-
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
})
|
|
240
217
|
|
|
241
|
-
|
|
242
|
-
.post('/dummy/standalone-prices/' + id)
|
|
243
|
-
.send({
|
|
244
|
-
version: 2,
|
|
245
|
-
actions: [
|
|
246
|
-
{
|
|
247
|
-
action: 'setDiscountedPrice',
|
|
248
|
-
discounted: null,
|
|
249
|
-
},
|
|
250
|
-
],
|
|
251
|
-
})
|
|
218
|
+
expect(response.status).toBe(200)
|
|
252
219
|
|
|
253
|
-
|
|
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
|
+
})
|
|
254
251
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
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
|
+
|
|
264
|
+
expect(response2.status).toBe(200)
|
|
265
|
+
|
|
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,
|
|
274
284
|
})
|
|
275
|
-
})
|
|
285
|
+
})
|
|
286
|
+
})
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { StateDraft } from '@commercetools/platform-sdk'
|
|
1
|
+
import { type StateDraft } from '@commercetools/platform-sdk'
|
|
2
2
|
import supertest from 'supertest'
|
|
3
|
+
import { describe, expect, test } from 'vitest'
|
|
3
4
|
import { CommercetoolsMock } from '../index'
|
|
4
5
|
|
|
5
6
|
const ctMock = new CommercetoolsMock()
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import type { Store } from '@commercetools/platform-sdk'
|
|
1
2
|
import supertest from 'supertest'
|
|
3
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'vitest'
|
|
2
4
|
import { CommercetoolsMock } from '../index'
|
|
3
5
|
|
|
4
6
|
const ctMock = new CommercetoolsMock()
|
|
@@ -23,6 +25,7 @@ describe('Store', () => {
|
|
|
23
25
|
createdAt: '',
|
|
24
26
|
lastModifiedAt: '',
|
|
25
27
|
key: 'STOREKEY',
|
|
28
|
+
countries: [],
|
|
26
29
|
languages: [],
|
|
27
30
|
distributionChannels: [],
|
|
28
31
|
supplyChannels: [],
|
|
@@ -40,11 +43,12 @@ describe('Store', () => {
|
|
|
40
43
|
id: 'fake-store',
|
|
41
44
|
key: 'STOREKEY',
|
|
42
45
|
lastModifiedAt: '',
|
|
46
|
+
countries: [],
|
|
43
47
|
languages: [],
|
|
44
48
|
distributionChannels: [],
|
|
45
49
|
supplyChannels: [],
|
|
46
50
|
productSelections: [],
|
|
47
|
-
})
|
|
51
|
+
} as Store)
|
|
48
52
|
})
|
|
49
53
|
|
|
50
54
|
test('Get store by 404 when not found by key', async () => {
|
|
@@ -54,6 +58,7 @@ describe('Store', () => {
|
|
|
54
58
|
createdAt: '',
|
|
55
59
|
lastModifiedAt: '',
|
|
56
60
|
key: 'STOREKEY',
|
|
61
|
+
countries: [],
|
|
57
62
|
languages: [],
|
|
58
63
|
distributionChannels: [],
|
|
59
64
|
supplyChannels: [],
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { TaxCategoryDraft } from '@commercetools/platform-sdk'
|
|
1
|
+
import type { TaxCategoryDraft } from '@commercetools/platform-sdk'
|
|
2
2
|
import supertest from 'supertest'
|
|
3
|
+
import { afterEach, describe, expect, test } from 'vitest'
|
|
3
4
|
import { CommercetoolsMock } from '../index'
|
|
4
5
|
|
|
5
6
|
const ctMock = new CommercetoolsMock()
|
package/src/storage/abstract.ts
CHANGED
package/src/storage/in-memory.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type {
|
|
2
|
+
AssociateRole,
|
|
3
|
+
AttributeGroup,
|
|
4
|
+
BusinessUnit,
|
|
2
5
|
Cart,
|
|
3
6
|
CartDiscount,
|
|
4
7
|
Category,
|
|
@@ -65,6 +68,9 @@ export class InMemoryStorage extends AbstractStorage {
|
|
|
65
68
|
let projectStorage = this.resources[projectKey]
|
|
66
69
|
if (!projectStorage) {
|
|
67
70
|
projectStorage = this.resources[projectKey] = {
|
|
71
|
+
'associate-role': new Map<string, AssociateRole>(),
|
|
72
|
+
'attribute-group': new Map<string, AttributeGroup>(),
|
|
73
|
+
'business-unit': new Map<string, BusinessUnit>(),
|
|
68
74
|
cart: new Map<string, Cart>(),
|
|
69
75
|
'cart-discount': new Map<string, CartDiscount>(),
|
|
70
76
|
category: new Map<string, Category>(),
|
package/src/types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as ctp from '@commercetools/platform-sdk'
|
|
1
|
+
import type * as ctp from '@commercetools/platform-sdk'
|
|
2
2
|
import { RepositoryMap } from './repositories'
|
|
3
3
|
import AbstractService from './services/abstract'
|
|
4
4
|
|
|
@@ -21,6 +21,9 @@ export type Services = Partial<{
|
|
|
21
21
|
export type ResourceType = keyof ResourceMap & keyof RepositoryMap
|
|
22
22
|
|
|
23
23
|
export type ResourceMap = {
|
|
24
|
+
'attribute-group': ctp.AttributeGroup
|
|
25
|
+
'associate-role': ctp.AssociateRole
|
|
26
|
+
'business-unit': ctp.BusinessUnit
|
|
24
27
|
'cart-discount': ctp.CartDiscount
|
|
25
28
|
cart: ctp.Cart
|
|
26
29
|
category: ctp.Category
|
|
@@ -58,6 +61,9 @@ export type ResourceMap = {
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
export type PagedQueryResponseMap = {
|
|
64
|
+
'attribute-group': ctp.AttributeGroupPagedQueryResponse
|
|
65
|
+
'associate-role': ctp.AssociateRolePagedQueryResponse
|
|
66
|
+
'business-unit': ctp.BusinessUnitPagedQueryResponse
|
|
61
67
|
'cart-discount': ctp.CartDiscountPagedQueryResponse
|
|
62
68
|
cart: ctp.CartPagedQueryResponse
|
|
63
69
|
category: ctp.CategoryPagedQueryResponse
|