|
1
|
import { IPricingModuleService } from "@medusajs/framework/types" |
|
2
|
import { Module, Modules } from "@medusajs/framework/utils" |
|
3
|
import { PricingModuleService } from "@services" |
|
4
|
import { moduleIntegrationTestRunner } from "@medusajs/test-utils" |
|
5
|
|
|
6
|
moduleIntegrationTestRunner<IPricingModuleService>({ |
|
7
|
moduleName: Modules.PRICING, |
|
8
|
testSuite: () => { |
|
9
|
describe("PricingModule Service - Calculate Price", () => { |
|
10
|
it(`should export the appropriate linkable configuration`, () => { |
|
11
|
const linkable = Module(Modules.PRICING, { |
|
12
|
service: PricingModuleService, |
|
13
|
}).linkable |
|
14
|
|
|
15
|
expect(Object.keys(linkable)).toEqual([ |
|
16
|
"priceSet", |
|
17
|
"priceList", |
|
18
|
"price", |
|
19
|
"pricePreference", |
|
20
|
]) |
|
21
|
|
|
22
|
Object.keys(linkable).forEach((key) => { |
|
23
|
delete linkable[key].toJSON |
|
24
|
}) |
|
25
|
|
|
26
|
expect(linkable).toEqual({ |
|
27
|
priceSet: { |
|
28
|
id: { |
|
29
|
linkable: "price_set_id", |
|
30
|
entity: "PriceSet", |
|
31
|
primaryKey: "id", |
|
32
|
serviceName: "pricing", |
|
33
|
field: "priceSet", |
|
34
|
}, |
|
35
|
}, |
|
36
|
priceList: { |
|
37
|
id: { |
|
38
|
linkable: "price_list_id", |
|
39
|
entity: "PriceList", |
|
40
|
primaryKey: "id", |
|
41
|
serviceName: "pricing", |
|
42
|
field: "priceList", |
|
43
|
}, |
|
44
|
}, |
|
45
|
price: { |
|
46
|
id: { |
|
47
|
linkable: "price_id", |
|
48
|
entity: "Price", |
|
49
|
primaryKey: "id", |
|
50
|
serviceName: "pricing", |
|
51
|
field: "price", |
|
52
|
}, |
|
53
|
}, |
|
54
|
pricePreference: { |
|
55
|
id: { |
|
56
|
linkable: "price_preference_id", |
|
57
|
entity: "PricePreference", |
|
58
|
primaryKey: "id", |
|
59
|
serviceName: "pricing", |
|
60
|
field: "pricePreference", |
|
61
|
}, |
|
62
|
}, |
|
63
|
}) |
|
64
|
}) |
|
65
|
}) |
|
66
|
}, |
|
67
|
}) |