|
1
|
import { medusaIntegrationTestRunner } from "@medusajs/test-utils" |
|
2
|
import { ITaxModuleService } from "@medusajs/types" |
|
3
|
import { Modules } from "@medusajs/utils" |
|
4
|
import { createAdminUser } from "../../../../helpers/create-admin-user" |
|
5
|
|
|
6
|
jest.setTimeout(50000) |
|
7
|
|
|
8
|
const env = {} |
|
9
|
const adminHeaders = { |
|
10
|
headers: { "x-medusa-access-token": "test_token" }, |
|
11
|
} |
|
12
|
|
|
13
|
medusaIntegrationTestRunner({ |
|
14
|
env, |
|
15
|
testSuite: ({ dbConnection, getContainer, api, dbUtils }) => { |
|
16
|
describe("Taxes - Admin", () => { |
|
17
|
let appContainer |
|
18
|
let service: ITaxModuleService |
|
19
|
|
|
20
|
beforeAll(async () => { |
|
21
|
appContainer = getContainer() |
|
22
|
service = appContainer.resolve(Modules.TAX) |
|
23
|
}) |
|
24
|
|
|
25
|
beforeAll(async () => { |
|
26
|
await createAdminUser(dbConnection, adminHeaders, appContainer) |
|
27
|
|
|
28
|
await dbUtils.snapshot() |
|
29
|
}) |
|
30
|
|
|
31
|
it("should load local provider and custom provider", async () => { |
|
32
|
const providers = await service.listTaxProviders() |
|
33
|
|
|
34
|
expect(providers).toEqual( |
|
35
|
expect.arrayContaining([ |
|
36
|
expect.objectContaining({ id: "tp_system", is_enabled: true }), |
|
37
|
expect.objectContaining({ |
|
38
|
id: "tp_system_system_2", |
|
39
|
is_enabled: true, |
|
40
|
}), |
|
41
|
]) |
|
42
|
) |
|
43
|
}) |
|
44
|
|
|
45
|
it("can retrieve a tax rate", async () => { |
|
46
|
const region = await service.createTaxRegions({ |
|
47
|
country_code: "us", |
|
48
|
}) |
|
49
|
const rate = await service.createTaxRates({ |
|
50
|
tax_region_id: region.id, |
|
51
|
code: "test", |
|
52
|
rate: 2.5, |
|
53
|
name: "Test Rate", |
|
54
|
}) |
|
55
|
|
|
56
|
const response = await api.get( |
|
57
|
`/admin/tax-rates/${rate.id}`, |
|
58
|
adminHeaders |
|
59
|
) |
|
60
|
|
|
61
|
expect(response.status).toEqual(200) |
|
62
|
expect(response.data).toEqual({ |
|
63
|
tax_rate: { |
|
64
|
id: rate.id, |
|
65
|
code: "test", |
|
66
|
rate: 2.5, |
|
67
|
name: "Test Rate", |
|
68
|
metadata: null, |
|
69
|
tax_region_id: region.id, |
|
70
|
is_default: false, |
|
71
|
is_combinable: false, |
|
72
|
created_at: expect.any(String), |
|
73
|
updated_at: expect.any(String), |
|
74
|
deleted_at: null, |
|
75
|
created_by: null, |
|
76
|
rules: [], |
|
77
|
tax_region: expect.any(Object), |
|
78
|
}, |
|
79
|
}) |
|
80
|
}) |
|
81
|
|
|
82
|
it("can search through tax rates", async () => { |
|
83
|
const region = await service.createTaxRegions({ |
|
84
|
country_code: "us", |
|
85
|
}) |
|
86
|
|
|
87
|
await service.createTaxRates({ |
|
88
|
tax_region_id: region.id, |
|
89
|
code: "low", |
|
90
|
rate: 2.5, |
|
91
|
name: "low rate", |
|
92
|
}) |
|
93
|
|
|
94
|
await service.createTaxRates({ |
|
95
|
tax_region_id: region.id, |
|
96
|
code: "high", |
|
97
|
rate: 5, |
|
98
|
name: "high rate", |
|
99
|
}) |
|
100
|
|
|
101
|
const response = await api.get(`/admin/tax-rates?q=high`, adminHeaders) |
|
102
|
|
|
103
|
expect(response.status).toEqual(200) |
|
104
|
expect(response.data.tax_rates).toEqual( |
|
105
|
expect.arrayContaining([expect.objectContaining({ code: "high" })]) |
|
106
|
) |
|
107
|
}) |
|
108
|
|
|
109
|
it("can create a tax region with rates and rules", async () => { |
|
110
|
const regionRes = await api.post( |
|
111
|
`/admin/tax-regions`, |
|
112
|
{ |
|
113
|
country_code: "us", |
|
114
|
provider_id: "tp_system", |
|
115
|
default_tax_rate: { |
|
116
|
code: "default", |
|
117
|
rate: 2, |
|
118
|
name: "default rate", |
|
119
|
}, |
|
120
|
}, |
|
121
|
adminHeaders |
|
122
|
) |
|
123
|
|
|
124
|
const usRegionId = regionRes.data.tax_region.id |
|
125
|
|
|
126
|
expect(regionRes.status).toEqual(200) |
|
127
|
expect(regionRes.data).toEqual({ |
|
128
|
tax_region: { |
|
129
|
id: expect.any(String), |
|
130
|
country_code: "us", |
|
131
|
parent_id: null, |
|
132
|
province_code: null, |
|
133
|
created_at: expect.any(String), |
|
134
|
updated_at: expect.any(String), |
|
135
|
deleted_at: null, |
|
136
|
created_by: expect.any(String), |
|
137
|
provider_id: "tp_system", |
|
138
|
metadata: null, |
|
139
|
children: [], |
|
140
|
parent: null, |
|
141
|
tax_rates: expect.any(Array), |
|
142
|
}, |
|
143
|
}) |
|
144
|
|
|
145
|
const rateRes = await api.post( |
|
146
|
`/admin/tax-rates`, |
|
147
|
{ |
|
148
|
tax_region_id: usRegionId, |
|
149
|
code: "RATE2", |
|
150
|
name: "another rate", |
|
151
|
rate: 10, |
|
152
|
rules: [{ reference: "product", reference_id: "prod_1234" }], |
|
153
|
}, |
|
154
|
adminHeaders |
|
155
|
) |
|
156
|
|
|
157
|
expect(rateRes.status).toEqual(200) |
|
158
|
expect(rateRes.data).toEqual({ |
|
159
|
tax_rate: { |
|
160
|
id: expect.any(String), |
|
161
|
code: "RATE2", |
|
162
|
rate: 10, |
|
163
|
name: "another rate", |
|
164
|
is_default: false, |
|
165
|
metadata: null, |
|
166
|
tax_region_id: usRegionId, |
|
167
|
created_at: expect.any(String), |
|
168
|
updated_at: expect.any(String), |
|
169
|
deleted_at: null, |
|
170
|
created_by: expect.any(String), |
|
171
|
is_combinable: false, |
|
172
|
tax_region: expect.any(Object), |
|
173
|
rules: [ |
|
174
|
expect.objectContaining({ |
|
175
|
reference: "product", |
|
176
|
reference_id: "prod_1234", |
|
177
|
}), |
|
178
|
], |
|
179
|
}, |
|
180
|
}) |
|
181
|
|
|
182
|
const provRegRes = await api.post( |
|
183
|
`/admin/tax-regions`, |
|
184
|
{ |
|
185
|
country_code: "US", |
|
186
|
parent_id: usRegionId, |
|
187
|
province_code: "cA", |
|
188
|
}, |
|
189
|
adminHeaders |
|
190
|
) |
|
191
|
|
|
192
|
expect(provRegRes.status).toEqual(200) |
|
193
|
expect(provRegRes.data).toEqual({ |
|
194
|
tax_region: { |
|
195
|
id: expect.any(String), |
|
196
|
country_code: "us", |
|
197
|
parent_id: usRegionId, |
|
198
|
province_code: "ca", |
|
199
|
created_at: expect.any(String), |
|
200
|
updated_at: expect.any(String), |
|
201
|
deleted_at: null, |
|
202
|
created_by: expect.any(String), |
|
203
|
metadata: null, |
|
204
|
provider_id: null, |
|
205
|
children: [], |
|
206
|
tax_rates: [], |
|
207
|
parent: expect.objectContaining({ |
|
208
|
id: usRegionId, |
|
209
|
}), |
|
210
|
}, |
|
211
|
}) |
|
212
|
|
|
213
|
const defRes = await api.post( |
|
214
|
`/admin/tax-rates`, |
|
215
|
{ |
|
216
|
tax_region_id: provRegRes.data.tax_region.id, |
|
217
|
code: "DEFAULT", |
|
218
|
name: "DEFAULT", |
|
219
|
rate: 10, |
|
220
|
is_default: true, |
|
221
|
}, |
|
222
|
adminHeaders |
|
223
|
) |
|
224
|
|
|
225
|
const listRes = await api.get(`/admin/tax-rates`, adminHeaders) |
|
226
|
|
|
227
|
expect(listRes.status).toEqual(200) |
|
228
|
expect(listRes.data.tax_rates).toEqual( |
|
229
|
expect.arrayContaining([ |
|
230
|
expect.objectContaining({ |
|
231
|
id: rateRes.data.tax_rate.id, |
|
232
|
code: "RATE2", |
|
233
|
rate: 10, |
|
234
|
name: "another rate", |
|
235
|
is_default: false, |
|
236
|
metadata: null, |
|
237
|
tax_region_id: usRegionId, |
|
238
|
created_at: expect.any(String), |
|
239
|
updated_at: expect.any(String), |
|
240
|
deleted_at: null, |
|
241
|
created_by: expect.any(String), |
|
242
|
}), |
|
243
|
expect.objectContaining({ id: defRes.data.tax_rate.id }), |
|
244
|
expect.objectContaining({ |
|
245
|
tax_region_id: usRegionId, |
|
246
|
is_default: true, |
|
247
|
rate: 2, |
|
248
|
}), |
|
249
|
]) |
|
250
|
) |
|
251
|
}) |
|
252
|
|
|
253
|
it("should fail to create a tax rate without a code", async () => { |
|
254
|
const errResponse = await api |
|
255
|
.post( |
|
256
|
`/admin/tax-regions`, |
|
257
|
{ |
|
258
|
country_code: "us", |
|
259
|
default_tax_rate: { |
|
260
|
rate: 2, |
|
261
|
name: "default rate", |
|
262
|
}, |
|
263
|
}, |
|
264
|
adminHeaders |
|
265
|
) |
|
266
|
.catch((e) => e) |
|
267
|
|
|
268
|
expect(errResponse.response.status).toEqual(400) |
|
269
|
expect(errResponse.response.data).toEqual({ |
|
270
|
message: |
|
271
|
"Invalid request: Field 'default_tax_rate, code' is required", |
|
272
|
type: "invalid_data", |
|
273
|
}) |
|
274
|
}) |
|
275
|
|
|
276
|
it("can create a tax rate and update it", async () => { |
|
277
|
const regionRes = await api.post( |
|
278
|
`/admin/tax-regions`, |
|
279
|
{ |
|
280
|
country_code: "us", |
|
281
|
provider_id: "tp_system", |
|
282
|
default_tax_rate: { |
|
283
|
code: "default", |
|
284
|
rate: 2, |
|
285
|
name: "default rate", |
|
286
|
}, |
|
287
|
}, |
|
288
|
adminHeaders |
|
289
|
) |
|
290
|
|
|
291
|
const usRegionId = regionRes.data.tax_region.id |
|
292
|
|
|
293
|
expect(regionRes.status).toEqual(200) |
|
294
|
expect(regionRes.data).toEqual({ |
|
295
|
tax_region: { |
|
296
|
id: expect.any(String), |
|
297
|
country_code: "us", |
|
298
|
parent_id: null, |
|
299
|
province_code: null, |
|
300
|
created_at: expect.any(String), |
|
301
|
updated_at: expect.any(String), |
|
302
|
deleted_at: null, |
|
303
|
created_by: expect.any(String), |
|
304
|
provider_id: "tp_system", |
|
305
|
metadata: null, |
|
306
|
children: [], |
|
307
|
parent: null, |
|
308
|
tax_rates: expect.any(Array), |
|
309
|
}, |
|
310
|
}) |
|
311
|
|
|
312
|
const rateRes = await api.post( |
|
313
|
`/admin/tax-rates`, |
|
314
|
{ |
|
315
|
tax_region_id: usRegionId, |
|
316
|
code: "RATE2", |
|
317
|
name: "another rate", |
|
318
|
rate: 10, |
|
319
|
rules: [{ reference: "product", reference_id: "prod_1234" }], |
|
320
|
}, |
|
321
|
adminHeaders |
|
322
|
) |
|
323
|
|
|
324
|
expect(rateRes.status).toEqual(200) |
|
325
|
expect(rateRes.data).toEqual({ |
|
326
|
tax_rate: { |
|
327
|
id: expect.any(String), |
|
328
|
code: "RATE2", |
|
329
|
rate: 10, |
|
330
|
name: "another rate", |
|
331
|
is_default: false, |
|
332
|
metadata: null, |
|
333
|
tax_region_id: usRegionId, |
|
334
|
created_at: expect.any(String), |
|
335
|
updated_at: expect.any(String), |
|
336
|
deleted_at: null, |
|
337
|
created_by: expect.any(String), |
|
338
|
is_combinable: false, |
|
339
|
tax_region: expect.any(Object), |
|
340
|
rules: [ |
|
341
|
expect.objectContaining({ |
|
342
|
reference: "product", |
|
343
|
reference_id: "prod_1234", |
|
344
|
}), |
|
345
|
], |
|
346
|
}, |
|
347
|
}) |
|
348
|
|
|
349
|
const updateRes = await api.post( |
|
350
|
`/admin/tax-rates/${rateRes.data.tax_rate.id}`, |
|
351
|
{ |
|
352
|
code: "updatedcode", |
|
353
|
rate: 12, |
|
354
|
is_combinable: true, |
|
355
|
name: "Another Name", |
|
356
|
metadata: { you: "know it" }, |
|
357
|
}, |
|
358
|
adminHeaders |
|
359
|
) |
|
360
|
|
|
361
|
expect(updateRes.status).toEqual(200) |
|
362
|
expect(updateRes.data).toEqual({ |
|
363
|
tax_rate: { |
|
364
|
id: expect.any(String), |
|
365
|
code: "updatedcode", |
|
366
|
rate: 12, |
|
367
|
name: "Another Name", |
|
368
|
is_default: false, |
|
369
|
metadata: { you: "know it" }, |
|
370
|
tax_region_id: usRegionId, |
|
371
|
deleted_at: null, |
|
372
|
created_at: expect.any(String), |
|
373
|
updated_at: expect.any(String), |
|
374
|
created_by: expect.any(String), |
|
375
|
is_combinable: true, |
|
376
|
tax_region: expect.any(Object), |
|
377
|
rules: [ |
|
378
|
expect.objectContaining({ |
|
379
|
reference: "product", |
|
380
|
reference_id: "prod_1234", |
|
381
|
}), |
|
382
|
], |
|
383
|
}, |
|
384
|
}) |
|
385
|
}) |
|
386
|
|
|
387
|
it("can create a tax rate and delete it", async () => { |
|
388
|
const regionRes = await api.post( |
|
389
|
`/admin/tax-regions`, |
|
390
|
{ |
|
391
|
country_code: "us", |
|
392
|
provider_id: "tp_system", |
|
393
|
default_tax_rate: { |
|
394
|
code: "default", |
|
395
|
rate: 2, |
|
396
|
name: "default rate", |
|
397
|
}, |
|
398
|
}, |
|
399
|
adminHeaders |
|
400
|
) |
|
401
|
|
|
402
|
const usRegionId = regionRes.data.tax_region.id |
|
403
|
|
|
404
|
const rateRes = await api.post( |
|
405
|
`/admin/tax-rates`, |
|
406
|
{ |
|
407
|
tax_region_id: usRegionId, |
|
408
|
code: "RATE2", |
|
409
|
name: "another rate", |
|
410
|
rate: 10, |
|
411
|
rules: [{ reference: "product", reference_id: "prod_1234" }], |
|
412
|
}, |
|
413
|
adminHeaders |
|
414
|
) |
|
415
|
|
|
416
|
const deleteRes = await api.delete( |
|
417
|
`/admin/tax-rates/${rateRes.data.tax_rate.id}`, |
|
418
|
adminHeaders |
|
419
|
) |
|
420
|
|
|
421
|
expect(deleteRes.status).toEqual(200) |
|
422
|
expect(deleteRes.data).toEqual({ |
|
423
|
id: rateRes.data.tax_rate.id, |
|
424
|
object: "tax_rate", |
|
425
|
deleted: true, |
|
426
|
}) |
|
427
|
|
|
428
|
const rates = await service.listTaxRates( |
|
429
|
{ id: rateRes.data.tax_rate.id }, |
|
430
|
{ withDeleted: true } |
|
431
|
) |
|
432
|
expect(rates.length).toEqual(1) |
|
433
|
expect(rates[0].deleted_at).not.toBeNull() |
|
434
|
}) |
|
435
|
|
|
436
|
it("can retrieve a tax region", async () => { |
|
437
|
const region = await service.createTaxRegions({ |
|
438
|
country_code: "us", |
|
439
|
}) |
|
440
|
|
|
441
|
const rate = await service.createTaxRates({ |
|
442
|
tax_region_id: region.id, |
|
443
|
code: "test", |
|
444
|
rate: 2.5, |
|
445
|
name: "Test Rate", |
|
446
|
}) |
|
447
|
|
|
448
|
const response = await api.get( |
|
449
|
`/admin/tax-regions/${region.id}`, |
|
450
|
adminHeaders |
|
451
|
) |
|
452
|
|
|
453
|
expect(response.status).toEqual(200) |
|
454
|
expect(response.data).toEqual({ |
|
455
|
tax_region: { |
|
456
|
id: region.id, |
|
457
|
country_code: "us", |
|
458
|
province_code: null, |
|
459
|
parent_id: null, |
|
460
|
provider_id: null, |
|
461
|
created_by: null, |
|
462
|
created_at: expect.any(String), |
|
463
|
updated_at: expect.any(String), |
|
464
|
tax_rates: expect.any(Array), |
|
465
|
deleted_at: null, |
|
466
|
metadata: null, |
|
467
|
children: [], |
|
468
|
parent: null, |
|
469
|
}, |
|
470
|
}) |
|
471
|
}) |
|
472
|
|
|
473
|
it("can search through tax regions", async () => { |
|
474
|
await service.createTaxRegions([ |
|
475
|
{ |
|
476
|
country_code: "us", |
|
477
|
province_code: "texas", |
|
478
|
}, |
|
479
|
{ |
|
480
|
country_code: "us", |
|
481
|
province_code: "florida", |
|
482
|
}, |
|
483
|
]) |
|
484
|
|
|
485
|
const response = await api.get(`/admin/tax-regions?q=ida`, adminHeaders) |
|
486
|
|
|
487
|
expect(response.status).toEqual(200) |
|
488
|
expect(response.data.tax_regions).toEqual( |
|
489
|
expect.arrayContaining([ |
|
490
|
expect.objectContaining({ |
|
491
|
country_code: "us", |
|
492
|
province_code: "florida", |
|
493
|
}), |
|
494
|
]) |
|
495
|
) |
|
496
|
}) |
|
497
|
|
|
498
|
it("can create a tax region and delete it", async () => { |
|
499
|
const regionRes = await api.post( |
|
500
|
`/admin/tax-regions`, |
|
501
|
{ |
|
502
|
country_code: "us", |
|
503
|
provider_id: "tp_system", |
|
504
|
default_tax_rate: { |
|
505
|
code: "default", |
|
506
|
rate: 2, |
|
507
|
name: "default rate", |
|
508
|
}, |
|
509
|
}, |
|
510
|
adminHeaders |
|
511
|
) |
|
512
|
|
|
513
|
const usRegionId = regionRes.data.tax_region.id |
|
514
|
|
|
515
|
const deleteRes = await api.delete( |
|
516
|
`/admin/tax-regions/${usRegionId}`, |
|
517
|
adminHeaders |
|
518
|
) |
|
519
|
|
|
520
|
expect(deleteRes.status).toEqual(200) |
|
521
|
expect(deleteRes.data).toEqual({ |
|
522
|
id: usRegionId, |
|
523
|
object: "tax_region", |
|
524
|
deleted: true, |
|
525
|
}) |
|
526
|
|
|
527
|
const rates = await service.listTaxRegions( |
|
528
|
{ id: usRegionId }, |
|
529
|
{ withDeleted: true } |
|
530
|
) |
|
531
|
expect(rates.length).toEqual(1) |
|
532
|
expect(rates[0].deleted_at).not.toBeNull() |
|
533
|
}) |
|
534
|
|
|
535
|
it("can create a tax rate add rules and remove them", async () => { |
|
536
|
const regionRes = await api.post( |
|
537
|
`/admin/tax-regions`, |
|
538
|
{ |
|
539
|
country_code: "us", |
|
540
|
provider_id: "tp_system", |
|
541
|
default_tax_rate: { |
|
542
|
code: "default", |
|
543
|
rate: 2, |
|
544
|
name: "default rate", |
|
545
|
}, |
|
546
|
}, |
|
547
|
adminHeaders |
|
548
|
) |
|
549
|
|
|
550
|
const usRegionId = regionRes.data.tax_region.id |
|
551
|
const rateRes = await api.post( |
|
552
|
`/admin/tax-rates`, |
|
553
|
{ |
|
554
|
tax_region_id: usRegionId, |
|
555
|
code: "RATE2", |
|
556
|
name: "another rate", |
|
557
|
rate: 10, |
|
558
|
rules: [{ reference: "product", reference_id: "prod_1234" }], |
|
559
|
}, |
|
560
|
adminHeaders |
|
561
|
) |
|
562
|
const rateId = rateRes.data.tax_rate.id |
|
563
|
let rules = await service.listTaxRateRules({ tax_rate_id: rateId }) |
|
564
|
|
|
565
|
expect(rules).toEqual([ |
|
566
|
{ |
|
567
|
id: expect.any(String), |
|
568
|
tax_rate_id: rateId, |
|
569
|
reference: "product", |
|
570
|
reference_id: "prod_1234", |
|
571
|
created_by: expect.any(String), |
|
572
|
created_at: expect.any(Date), |
|
573
|
updated_at: expect.any(Date), |
|
574
|
deleted_at: null, |
|
575
|
tax_rate: { id: rateId }, |
|
576
|
metadata: null, |
|
577
|
}, |
|
578
|
]) |
|
579
|
|
|
580
|
await api.post( |
|
581
|
`/admin/tax-rates/${rateId}/rules`, |
|
582
|
{ |
|
583
|
reference: "product", |
|
584
|
reference_id: "prod_1111", |
|
585
|
}, |
|
586
|
adminHeaders |
|
587
|
) |
|
588
|
|
|
589
|
await api.post( |
|
590
|
`/admin/tax-rates/${rateId}/rules`, |
|
591
|
{ |
|
592
|
reference: "product", |
|
593
|
reference_id: "prod_2222", |
|
594
|
}, |
|
595
|
adminHeaders |
|
596
|
) |
|
597
|
rules = await service.listTaxRateRules({ tax_rate_id: rateId }) |
|
598
|
expect(rules).toEqual( |
|
599
|
expect.arrayContaining([ |
|
600
|
expect.objectContaining({ |
|
601
|
tax_rate_id: rateId, |
|
602
|
reference: "product", |
|
603
|
reference_id: "prod_1234", |
|
604
|
created_by: expect.any(String), |
|
605
|
}), |
|
606
|
expect.objectContaining({ |
|
607
|
tax_rate_id: rateId, |
|
608
|
reference: "product", |
|
609
|
reference_id: "prod_1111", |
|
610
|
created_by: expect.any(String), |
|
611
|
}), |
|
612
|
expect.objectContaining({ |
|
613
|
tax_rate_id: rateId, |
|
614
|
reference: "product", |
|
615
|
reference_id: "prod_2222", |
|
616
|
created_by: expect.any(String), |
|
617
|
}), |
|
618
|
]) |
|
619
|
) |
|
620
|
|
|
621
|
const toDeleteId = rules.find((r) => r.reference_id === "prod_1111")!.id |
|
622
|
await api.delete( |
|
623
|
`/admin/tax-rates/${rateId}/rules/${toDeleteId}`, |
|
624
|
adminHeaders |
|
625
|
) |
|
626
|
|
|
627
|
rules = await service.listTaxRateRules({ tax_rate_id: rateId }) |
|
628
|
expect(rules.length).toEqual(2) |
|
629
|
|
|
630
|
await api.post( |
|
631
|
`/admin/tax-rates/${rateId}`, |
|
632
|
{ |
|
633
|
rules: [ |
|
634
|
{ reference: "product", reference_id: "prod_3333" }, |
|
635
|
{ reference: "product", reference_id: "prod_4444" }, |
|
636
|
{ reference: "product", reference_id: "prod_5555" }, |
|
637
|
{ reference: "product", reference_id: "prod_6666" }, |
|
638
|
], |
|
639
|
}, |
|
640
|
adminHeaders |
|
641
|
) |
|
642
|
rules = await service.listTaxRateRules({ tax_rate_id: rateId }) |
|
643
|
expect(rules.length).toEqual(4) |
|
644
|
expect(rules).toEqual( |
|
645
|
expect.arrayContaining([ |
|
646
|
expect.objectContaining({ |
|
647
|
tax_rate_id: rateId, |
|
648
|
reference: "product", |
|
649
|
reference_id: "prod_3333", |
|
650
|
created_by: expect.any(String), |
|
651
|
}), |
|
652
|
expect.objectContaining({ |
|
653
|
tax_rate_id: rateId, |
|
654
|
reference: "product", |
|
655
|
reference_id: "prod_4444", |
|
656
|
created_by: expect.any(String), |
|
657
|
}), |
|
658
|
expect.objectContaining({ |
|
659
|
tax_rate_id: rateId, |
|
660
|
reference: "product", |
|
661
|
reference_id: "prod_5555", |
|
662
|
created_by: expect.any(String), |
|
663
|
}), |
|
664
|
expect.objectContaining({ |
|
665
|
tax_rate_id: rateId, |
|
666
|
reference: "product", |
|
667
|
reference_id: "prod_6666", |
|
668
|
created_by: expect.any(String), |
|
669
|
}), |
|
670
|
]) |
|
671
|
) |
|
672
|
}) |
|
673
|
}) |
|
674
|
}, |
|
675
|
}) |