|
1
|
import { IOrderModuleService } from "@medusajs/framework/types" |
|
2
|
import { Module, Modules } from "@medusajs/framework/utils" |
|
3
|
import { moduleIntegrationTestRunner } from "@medusajs/test-utils" |
|
4
|
import { OrderModuleService } from "@services" |
|
5
|
|
|
6
|
moduleIntegrationTestRunner<IOrderModuleService>({ |
|
7
|
moduleName: Modules.ORDER, |
|
8
|
testSuite: () => { |
|
9
|
describe("Order Module Service", () => { |
|
10
|
it(`should export the appropriate linkable configuration`, () => { |
|
11
|
const linkable = Module(Modules.ORDER, { |
|
12
|
service: OrderModuleService, |
|
13
|
}).linkable |
|
14
|
|
|
15
|
expect(Object.keys(linkable)).toEqual( |
|
16
|
expect.arrayContaining([ |
|
17
|
"order", |
|
18
|
"orderAddress", |
|
19
|
"orderChange", |
|
20
|
"orderClaim", |
|
21
|
"orderExchange", |
|
22
|
"orderItem", |
|
23
|
"orderLineItem", |
|
24
|
"orderShippingMethod", |
|
25
|
"orderTransaction", |
|
26
|
"return", |
|
27
|
"returnReason", |
|
28
|
]) |
|
29
|
) |
|
30
|
|
|
31
|
Object.keys(linkable).forEach((key) => { |
|
32
|
delete linkable[key].toJSON |
|
33
|
}) |
|
34
|
|
|
35
|
expect(linkable).toEqual({ |
|
36
|
order: { |
|
37
|
id: { |
|
38
|
linkable: "order_id", |
|
39
|
entity: "Order", |
|
40
|
primaryKey: "id", |
|
41
|
serviceName: "order", |
|
42
|
field: "order", |
|
43
|
}, |
|
44
|
}, |
|
45
|
orderAddress: { |
|
46
|
id: { |
|
47
|
linkable: "order_address_id", |
|
48
|
entity: "OrderAddress", |
|
49
|
primaryKey: "id", |
|
50
|
serviceName: "order", |
|
51
|
field: "orderAddress", |
|
52
|
}, |
|
53
|
}, |
|
54
|
orderChange: { |
|
55
|
id: { |
|
56
|
linkable: "order_change_id", |
|
57
|
entity: "OrderChange", |
|
58
|
primaryKey: "id", |
|
59
|
serviceName: "order", |
|
60
|
field: "orderChange", |
|
61
|
}, |
|
62
|
}, |
|
63
|
orderClaim: { |
|
64
|
id: { |
|
65
|
linkable: "order_claim_id", |
|
66
|
entity: "OrderClaim", |
|
67
|
primaryKey: "id", |
|
68
|
serviceName: "order", |
|
69
|
field: "orderClaim", |
|
70
|
}, |
|
71
|
claim_id: { |
|
72
|
linkable: "claim_id", |
|
73
|
entity: "OrderClaim", |
|
74
|
primaryKey: "claim_id", |
|
75
|
serviceName: "order", |
|
76
|
field: "orderClaim", |
|
77
|
}, |
|
78
|
}, |
|
79
|
orderExchange: { |
|
80
|
id: { |
|
81
|
linkable: "order_exchange_id", |
|
82
|
entity: "OrderExchange", |
|
83
|
primaryKey: "id", |
|
84
|
serviceName: "order", |
|
85
|
field: "orderExchange", |
|
86
|
}, |
|
87
|
exchange_id: { |
|
88
|
linkable: "exchange_id", |
|
89
|
entity: "OrderExchange", |
|
90
|
primaryKey: "exchange_id", |
|
91
|
serviceName: "order", |
|
92
|
field: "orderExchange", |
|
93
|
}, |
|
94
|
}, |
|
95
|
orderItem: { |
|
96
|
id: { |
|
97
|
linkable: "order_item_id", |
|
98
|
entity: "OrderItem", |
|
99
|
primaryKey: "id", |
|
100
|
serviceName: "order", |
|
101
|
field: "orderItem", |
|
102
|
}, |
|
103
|
}, |
|
104
|
orderLineItem: { |
|
105
|
id: { |
|
106
|
linkable: "order_line_item_id", |
|
107
|
entity: "OrderLineItem", |
|
108
|
primaryKey: "id", |
|
109
|
serviceName: "order", |
|
110
|
field: "orderLineItem", |
|
111
|
}, |
|
112
|
}, |
|
113
|
orderShippingMethod: { |
|
114
|
id: { |
|
115
|
linkable: "order_shipping_method_id", |
|
116
|
entity: "OrderShippingMethod", |
|
117
|
primaryKey: "id", |
|
118
|
serviceName: "order", |
|
119
|
field: "orderShippingMethod", |
|
120
|
}, |
|
121
|
}, |
|
122
|
orderTransaction: { |
|
123
|
id: { |
|
124
|
linkable: "order_transaction_id", |
|
125
|
entity: "OrderTransaction", |
|
126
|
primaryKey: "id", |
|
127
|
serviceName: "order", |
|
128
|
field: "orderTransaction", |
|
129
|
}, |
|
130
|
}, |
|
131
|
return: { |
|
132
|
id: { |
|
133
|
linkable: "return_id", |
|
134
|
entity: "Return", |
|
135
|
primaryKey: "id", |
|
136
|
serviceName: "order", |
|
137
|
field: "return", |
|
138
|
}, |
|
139
|
}, |
|
140
|
returnReason: { |
|
141
|
id: { |
|
142
|
linkable: "return_reason_id", |
|
143
|
entity: "ReturnReason", |
|
144
|
primaryKey: "id", |
|
145
|
serviceName: "order", |
|
146
|
field: "returnReason", |
|
147
|
}, |
|
148
|
}, |
|
149
|
}) |
|
150
|
}) |
|
151
|
}) |
|
152
|
}, |
|
153
|
}) |