pure-orm 4.0.0 → 4.0.2
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 +97 -43
- package/coverage/clover.xml +969 -626
- package/coverage/coverage-final.json +34 -22
- package/coverage/lcov-report/dist/src/core.js.html +220 -190
- package/coverage/lcov-report/dist/src/driver-integrations/index.html +97 -0
- package/coverage/lcov-report/dist/src/driver-integrations/pgp.js.html +240 -0
- package/coverage/lcov-report/dist/src/index.html +44 -18
- package/coverage/lcov-report/dist/src/index.js.html +2 -2
- package/coverage/lcov-report/dist/src/orm.js.html +125 -119
- package/coverage/lcov-report/dist/test-utils/blog/entities.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/blog/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/blog/models/article.js.html +15 -15
- package/coverage/lcov-report/dist/test-utils/blog/models/article_tag.js.html +7 -7
- package/coverage/lcov-report/dist/test-utils/blog/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/blog/models/person.js.html +13 -13
- package/coverage/lcov-report/dist/test-utils/blog/models/tag.js.html +4 -4
- package/coverage/lcov-report/dist/test-utils/five/entities.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/five/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/five/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/five/models/line-item.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/five/models/order.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/five/models/parcel-event.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/five/models/parcel-line-item.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/five/models/parcel.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/fourteen/entities.js.html +87 -0
- package/coverage/lcov-report/dist/test-utils/fourteen/index.html +97 -0
- package/coverage/lcov-report/dist/test-utils/fourteen/models/customer.js.html +159 -0
- package/coverage/lcov-report/dist/test-utils/fourteen/models/index.html +110 -0
- package/coverage/lcov-report/dist/test-utils/fourteen/models/person.js.html +138 -0
- package/coverage/lcov-report/dist/test-utils/nine/entities.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/nine/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/nine/models/feature-switch.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/nine/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order/entities.js.html +11 -11
- package/coverage/lcov-report/dist/test-utils/order/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order/models/line-item.js.html +24 -24
- package/coverage/lcov-report/dist/test-utils/order/models/order.js.html +42 -42
- package/coverage/lcov-report/dist/test-utils/order/models/product-variant.js.html +23 -23
- package/coverage/lcov-report/dist/test-utils/order/models/product.js.html +17 -17
- package/coverage/lcov-report/dist/test-utils/order/models/utm-source.js.html +12 -12
- package/coverage/lcov-report/dist/test-utils/order-more/entities.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/actual-product-variant.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/color.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/customer.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/gender.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/inventory-level.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/line-item.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/order.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/parcel-event.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/parcel-line-item.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/parcel.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/physical-address.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/product-variant-image.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/product-variant.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/product.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/refund.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/shipment-actual-product-variant.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/shipment.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/size.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/utm-medium.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/order-more/models/utm-source.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/entities.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/models/customer.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/models/line-item.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/models/order.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/models/parcel-line-item.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/six/models/parcel.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/entities.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/audience.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/brand.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/category.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/member.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/passion.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/product.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/recommendation-audience.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/thirteen/models/recommendation.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/three/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/three/results.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/twelve/entities.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/twelve/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/twelve/models/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/twelve/models/member.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/twelve/models/prompt.js.html +1 -1
- package/coverage/lcov-report/dist/test-utils/two/index.html +1 -1
- package/coverage/lcov-report/dist/test-utils/two/results.js.html +1 -1
- package/coverage/lcov-report/index.html +105 -27
- package/coverage/lcov-report/src/core.ts.html +235 -196
- package/coverage/lcov-report/src/driver-integrations/index.html +97 -0
- package/coverage/lcov-report/src/driver-integrations/pgp.ts.html +345 -0
- package/coverage/lcov-report/src/index.html +44 -18
- package/coverage/lcov-report/src/index.ts.html +3 -15
- package/coverage/lcov-report/src/orm.ts.html +256 -130
- package/coverage/lcov-report/test-utils/blog/entities.ts.html +1 -1
- package/coverage/lcov-report/test-utils/blog/index.html +1 -1
- package/coverage/lcov-report/test-utils/blog/models/article.ts.html +15 -15
- package/coverage/lcov-report/test-utils/blog/models/article_tag.ts.html +7 -7
- package/coverage/lcov-report/test-utils/blog/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/blog/models/person.ts.html +13 -13
- package/coverage/lcov-report/test-utils/blog/models/tag.ts.html +4 -4
- package/coverage/lcov-report/test-utils/five/entities.ts.html +1 -1
- package/coverage/lcov-report/test-utils/five/index.html +1 -1
- package/coverage/lcov-report/test-utils/five/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/five/models/line-item.ts.html +1 -1
- package/coverage/lcov-report/test-utils/five/models/order.ts.html +1 -1
- package/coverage/lcov-report/test-utils/five/models/parcel-event.ts.html +1 -1
- package/coverage/lcov-report/test-utils/five/models/parcel-line-item.ts.html +1 -1
- package/coverage/lcov-report/test-utils/five/models/parcel.ts.html +1 -1
- package/coverage/lcov-report/test-utils/fourteen/entities.ts.html +78 -0
- package/coverage/lcov-report/test-utils/fourteen/index.html +97 -0
- package/coverage/lcov-report/test-utils/fourteen/models/customer.ts.html +177 -0
- package/coverage/lcov-report/test-utils/fourteen/models/index.html +110 -0
- package/coverage/lcov-report/test-utils/fourteen/models/person.ts.html +150 -0
- package/coverage/lcov-report/test-utils/nine/entities.ts.html +1 -1
- package/coverage/lcov-report/test-utils/nine/index.html +1 -1
- package/coverage/lcov-report/test-utils/nine/models/feature-switch.ts.html +1 -1
- package/coverage/lcov-report/test-utils/nine/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/order/entities.ts.html +5 -5
- package/coverage/lcov-report/test-utils/order/index.html +1 -1
- package/coverage/lcov-report/test-utils/order/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/order/models/line-item.ts.html +18 -18
- package/coverage/lcov-report/test-utils/order/models/order.ts.html +37 -37
- package/coverage/lcov-report/test-utils/order/models/product-variant.ts.html +18 -18
- package/coverage/lcov-report/test-utils/order/models/product.ts.html +13 -13
- package/coverage/lcov-report/test-utils/order/models/utm-source.ts.html +8 -8
- package/coverage/lcov-report/test-utils/order-more/entities.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/index.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/actual-product-variant.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/color.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/customer.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/gender.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/inventory-level.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/line-item.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/order.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/parcel-event.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/parcel-line-item.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/parcel.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/physical-address.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/product-variant-image.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/product-variant.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/product.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/refund.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/shipment-actual-product-variant.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/shipment.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/size.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/utm-medium.ts.html +1 -1
- package/coverage/lcov-report/test-utils/order-more/models/utm-source.ts.html +1 -1
- package/coverage/lcov-report/test-utils/six/entities.ts.html +1 -1
- package/coverage/lcov-report/test-utils/six/index.html +1 -1
- package/coverage/lcov-report/test-utils/six/models/customer.ts.html +1 -1
- package/coverage/lcov-report/test-utils/six/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/six/models/line-item.ts.html +1 -1
- package/coverage/lcov-report/test-utils/six/models/order.ts.html +1 -1
- package/coverage/lcov-report/test-utils/six/models/parcel-line-item.ts.html +1 -1
- package/coverage/lcov-report/test-utils/six/models/parcel.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/entities.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/index.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/audience.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/brand.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/category.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/member.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/passion.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/product.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/recommendation-audience.ts.html +1 -1
- package/coverage/lcov-report/test-utils/thirteen/models/recommendation.ts.html +1 -1
- package/coverage/lcov-report/test-utils/three/index.html +1 -1
- package/coverage/lcov-report/test-utils/three/results.js.html +1 -1
- package/coverage/lcov-report/test-utils/twelve/entities.ts.html +1 -1
- package/coverage/lcov-report/test-utils/twelve/index.html +1 -1
- package/coverage/lcov-report/test-utils/twelve/models/index.html +1 -1
- package/coverage/lcov-report/test-utils/twelve/models/member.ts.html +1 -1
- package/coverage/lcov-report/test-utils/twelve/models/prompt.ts.html +1 -1
- package/coverage/lcov-report/test-utils/two/index.html +1 -1
- package/coverage/lcov-report/test-utils/two/results.js.html +1 -1
- package/coverage/lcov.info +1686 -1005
- package/dist/src/core.d.ts +1 -1
- package/dist/src/core.js +18 -8
- package/dist/src/core.spec.js +643 -540
- package/dist/src/driver-integrations/index.d.ts +1 -0
- package/dist/src/orm.d.ts +21 -0
- package/dist/src/orm.js +6 -2
- package/dist/src/orm.spec.d.ts +1 -0
- package/dist/src/orm.spec.js +102 -0
- package/dist/test-utils/fourteen/entities.d.ts +6 -0
- package/dist/test-utils/fourteen/entities.js +6 -0
- package/dist/test-utils/fourteen/entities.ts +3 -0
- package/dist/test-utils/fourteen/models/customer.d.ts +19 -0
- package/dist/test-utils/fourteen/models/customer.js +30 -0
- package/dist/test-utils/fourteen/models/customer.ts +36 -0
- package/dist/test-utils/fourteen/models/person.d.ts +17 -0
- package/dist/test-utils/fourteen/models/person.js +23 -0
- package/dist/test-utils/fourteen/models/person.ts +27 -0
- package/dist/test-utils/fourteen/results.json +8 -0
- package/dist/test-utils/order/entities.js +2 -2
- package/dist/test-utils/order/entities.ts +2 -2
- package/dist/test-utils/order/models/order.js +1 -1
- package/dist/test-utils/order/models/order.ts +1 -1
- package/package.json +1 -1
- package/src/core.spec.ts +1112 -986
- package/src/core.ts +27 -14
- package/src/driver-integrations/index.ts +2 -0
- package/src/orm.spec.ts +113 -0
- package/src/orm.ts +54 -8
- package/test-utils/fourteen/entities.ts +3 -0
- package/test-utils/fourteen/models/customer.ts +36 -0
- package/test-utils/fourteen/models/person.ts +27 -0
- package/test-utils/fourteen/results.json +8 -0
- package/test-utils/order/entities.ts +2 -2
- package/test-utils/order/models/order.ts +1 -1
package/dist/src/core.spec.js
CHANGED
|
@@ -10,6 +10,7 @@ const entities_5 = require("../test-utils/five/entities");
|
|
|
10
10
|
const entities_6 = require("../test-utils/six/entities");
|
|
11
11
|
const entities_7 = require("../test-utils/twelve/entities");
|
|
12
12
|
const entities_8 = require("../test-utils/thirteen/entities");
|
|
13
|
+
const entities_9 = require("../test-utils/fourteen/entities");
|
|
13
14
|
const article_1 = require("../test-utils/blog/models/article");
|
|
14
15
|
const two = require('../test-utils/two/results');
|
|
15
16
|
const three = require('../test-utils/three/results');
|
|
@@ -24,551 +25,653 @@ const ten = require('../test-utils/ten/results.json');
|
|
|
24
25
|
const eleven = require('../test-utils/eleven/results.json');
|
|
25
26
|
const twelve = require('../test-utils/twelve/results.json');
|
|
26
27
|
const thirteen = require('../test-utils/thirteen/results.json');
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
//
|
|
126
|
-
//
|
|
127
|
-
//
|
|
128
|
-
// on the
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
//
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
//
|
|
185
|
-
//
|
|
186
|
-
//
|
|
187
|
-
//
|
|
188
|
-
//
|
|
189
|
-
//
|
|
190
|
-
//
|
|
191
|
-
test
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
//
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
//
|
|
228
|
-
//
|
|
229
|
-
// ParcelLineItem
|
|
230
|
-
// LineItem
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
//
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
//
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
//
|
|
261
|
-
// InventoryLevel
|
|
262
|
-
// ActualProductVariant
|
|
263
|
-
// ProductVariant
|
|
264
|
-
// Color
|
|
265
|
-
//
|
|
266
|
-
//
|
|
267
|
-
//
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
//
|
|
272
|
-
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
//
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
//
|
|
301
|
-
//
|
|
302
|
-
// ShipmentActualProductVariant
|
|
303
|
-
// ActualProductVariant
|
|
304
|
-
//
|
|
305
|
-
//
|
|
306
|
-
//
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
//
|
|
311
|
-
|
|
312
|
-
//
|
|
313
|
-
//
|
|
314
|
-
//
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
28
|
+
const fourteen = require('../test-utils/fourteen/results.json');
|
|
29
|
+
describe('createFromDatabase', () => {
|
|
30
|
+
test('multiple rows reduce to one nested object (with all one-to-one or one-to-many tables)', () => {
|
|
31
|
+
const core = (0, core_1.createCore)({ entities: entities_1.entities });
|
|
32
|
+
const orders = core.createFromDatabase(one);
|
|
33
|
+
expect(orders.models.length).toEqual(1);
|
|
34
|
+
const order = orders.models[0];
|
|
35
|
+
expect(order === null || order === void 0 ? void 0 : order.id).toEqual(3866);
|
|
36
|
+
expect(order === null || order === void 0 ? void 0 : order.utmSource.id).toEqual(6);
|
|
37
|
+
expect(order === null || order === void 0 ? void 0 : order.lineItems.models.length).toEqual(6);
|
|
38
|
+
expect(order.lineItems.models[0].id).toEqual(2271);
|
|
39
|
+
expect(order.lineItems.models[0].productVariant.id).toEqual(163);
|
|
40
|
+
expect(order.lineItems.models[0].productVariant.product.id).toEqual(1);
|
|
41
|
+
expect(order.lineItems.models[1].id).toEqual(2272);
|
|
42
|
+
expect(order.lineItems.models[1].productVariant.id).toEqual(186);
|
|
43
|
+
expect(order.lineItems.models[1].productVariant.product.id).toEqual(1);
|
|
44
|
+
expect(order.lineItems.models[2].id).toEqual(2273);
|
|
45
|
+
expect(order.lineItems.models[2].productVariant.id).toEqual(213);
|
|
46
|
+
expect(order.lineItems.models[2].productVariant.product.id).toEqual(1);
|
|
47
|
+
expect(order.lineItems.models[3].id).toEqual(2274);
|
|
48
|
+
expect(order.lineItems.models[3].productVariant.id).toEqual(207);
|
|
49
|
+
expect(order.lineItems.models[3].productVariant.product.id).toEqual(1);
|
|
50
|
+
expect(order.lineItems.models[4].id).toEqual(2275);
|
|
51
|
+
expect(order.lineItems.models[4].productVariant.id).toEqual(296);
|
|
52
|
+
expect(order.lineItems.models[4].productVariant.product.id).toEqual(5);
|
|
53
|
+
expect(order.lineItems.models[5].id).toEqual(2276);
|
|
54
|
+
expect(order.lineItems.models[5].productVariant.id).toEqual(308);
|
|
55
|
+
expect(order.lineItems.models[5].productVariant.product.id).toEqual(3);
|
|
56
|
+
});
|
|
57
|
+
test('createFromDatabase where multiple rows reduce to one nested object (with many-to-many tables)', () => {
|
|
58
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
59
|
+
const articles = core.createFromDatabase(two);
|
|
60
|
+
expect(articles.models.length).toEqual(1);
|
|
61
|
+
const article = articles.models[0];
|
|
62
|
+
expect(article.id).toEqual(14);
|
|
63
|
+
expect(article.person.id).toEqual(8);
|
|
64
|
+
expect(article.articleTags.models.length).toEqual(10);
|
|
65
|
+
expect(article.articleTags.models[0].id).toEqual(36);
|
|
66
|
+
expect(article.articleTags.models[0].tag.id).toEqual(3);
|
|
67
|
+
expect(article.articleTags.models[1].id).toEqual(37);
|
|
68
|
+
expect(article.articleTags.models[1].tag.id).toEqual(4);
|
|
69
|
+
expect(article.articleTags.models[2].id).toEqual(38);
|
|
70
|
+
expect(article.articleTags.models[2].tag.id).toEqual(5);
|
|
71
|
+
expect(article.articleTags.models[3].id).toEqual(39);
|
|
72
|
+
expect(article.articleTags.models[3].tag.id).toEqual(6);
|
|
73
|
+
expect(article.articleTags.models[4].id).toEqual(40);
|
|
74
|
+
expect(article.articleTags.models[4].tag.id).toEqual(7);
|
|
75
|
+
expect(article.articleTags.models[5].id).toEqual(41);
|
|
76
|
+
expect(article.articleTags.models[5].tag.id).toEqual(8);
|
|
77
|
+
expect(article.articleTags.models[6].id).toEqual(42);
|
|
78
|
+
expect(article.articleTags.models[6].tag.id).toEqual(9);
|
|
79
|
+
expect(article.articleTags.models[7].id).toEqual(43);
|
|
80
|
+
expect(article.articleTags.models[7].tag.id).toEqual(11);
|
|
81
|
+
expect(article.articleTags.models[8].id).toEqual(44);
|
|
82
|
+
expect(article.articleTags.models[8].tag.id).toEqual(12);
|
|
83
|
+
expect(article.articleTags.models[9].id).toEqual(45);
|
|
84
|
+
expect(article.articleTags.models[9].tag.id).toEqual(16);
|
|
85
|
+
});
|
|
86
|
+
test('multiple rows reduce to many rows with nested objects (with many-to-many tables)', () => {
|
|
87
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
88
|
+
const articles = core.createFromDatabase(three);
|
|
89
|
+
expect(Array.isArray(articles.models)).toBe(true);
|
|
90
|
+
expect(articles instanceof article_1.Articles).toBe(true);
|
|
91
|
+
expect(articles.models.length).toEqual(2);
|
|
92
|
+
const first = articles.models[0];
|
|
93
|
+
expect(first.person.id).toEqual(8);
|
|
94
|
+
expect(first.articleTags.models.length).toEqual(10);
|
|
95
|
+
expect(first.articleTags.models[0].id).toEqual(36);
|
|
96
|
+
expect(first.articleTags.models[0].tag.id).toEqual(3);
|
|
97
|
+
expect(first.articleTags.models[1].id).toEqual(37);
|
|
98
|
+
expect(first.articleTags.models[1].tag.id).toEqual(4);
|
|
99
|
+
expect(first.articleTags.models[2].id).toEqual(38);
|
|
100
|
+
expect(first.articleTags.models[2].tag.id).toEqual(5);
|
|
101
|
+
expect(first.articleTags.models[3].id).toEqual(39);
|
|
102
|
+
expect(first.articleTags.models[3].tag.id).toEqual(6);
|
|
103
|
+
expect(first.articleTags.models[4].id).toEqual(40);
|
|
104
|
+
expect(first.articleTags.models[4].tag.id).toEqual(7);
|
|
105
|
+
expect(first.articleTags.models[5].id).toEqual(41);
|
|
106
|
+
expect(first.articleTags.models[5].tag.id).toEqual(8);
|
|
107
|
+
expect(first.articleTags.models[6].id).toEqual(42);
|
|
108
|
+
expect(first.articleTags.models[6].tag.id).toEqual(9);
|
|
109
|
+
expect(first.articleTags.models[7].id).toEqual(43);
|
|
110
|
+
expect(first.articleTags.models[7].tag.id).toEqual(11);
|
|
111
|
+
expect(first.articleTags.models[8].id).toEqual(44);
|
|
112
|
+
expect(first.articleTags.models[8].tag.id).toEqual(12);
|
|
113
|
+
expect(first.articleTags.models[9].id).toEqual(45);
|
|
114
|
+
expect(first.articleTags.models[9].tag.id).toEqual(16);
|
|
115
|
+
const second = articles.models[1];
|
|
116
|
+
expect(second.id).toEqual(12);
|
|
117
|
+
expect(second.person.id).toEqual(17);
|
|
118
|
+
expect(second.articleTags.models.length).toEqual(3);
|
|
119
|
+
expect(second.articleTags.models[0].id).toEqual(33);
|
|
120
|
+
expect(second.articleTags.models[0].tag.id).toEqual(1);
|
|
121
|
+
expect(second.articleTags.models[1].id).toEqual(34);
|
|
122
|
+
expect(second.articleTags.models[1].tag.id).toEqual(5);
|
|
123
|
+
expect(second.articleTags.models[2].id).toEqual(35);
|
|
124
|
+
expect(second.articleTags.models[2].tag.id).toEqual(15);
|
|
125
|
+
});
|
|
126
|
+
// Tests for where a deeply nested node which points to a node, is itself
|
|
127
|
+
// reused (not recreated each time) so that nodes pointing to it all stack
|
|
128
|
+
// together on it, rather than each attaching to different replica nodes
|
|
129
|
+
// which overwrite themselves on the node it points to.
|
|
130
|
+
// The example here is with the productVariant node being reused so that
|
|
131
|
+
// productVariantImages append to it, instead of each productVariantImage
|
|
132
|
+
// living on its own productVariant (which would keep overwriting itself
|
|
133
|
+
// on the actualProductVariant node).
|
|
134
|
+
test('node is already seen', () => {
|
|
135
|
+
const core = (0, core_1.createCore)({ entities: entities_3.entities });
|
|
136
|
+
const inventoryLevels = core.createFromDatabase(four);
|
|
137
|
+
expect(inventoryLevels).toBeDefined();
|
|
138
|
+
const first = inventoryLevels === null || inventoryLevels === void 0 ? void 0 : inventoryLevels.models[0];
|
|
139
|
+
expect(first === null || first === void 0 ? void 0 : first.id).toEqual(15);
|
|
140
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.id).toEqual(120);
|
|
141
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models.length).toEqual(1);
|
|
142
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].actualProductVariantId).toEqual(120);
|
|
143
|
+
// I think the above test is good enough, and not sure I actual care about below
|
|
144
|
+
// expect(first.actualProductVariant.productVariants.models[0].actualProductVariant.id).toEqual(120);
|
|
145
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].id).toEqual(199);
|
|
146
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].color.id).toEqual(1);
|
|
147
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].gender.id).toEqual(1);
|
|
148
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].product.id).toEqual(1);
|
|
149
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].size.id).toEqual(4);
|
|
150
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models.length).toEqual(7);
|
|
151
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models[0].id).toEqual(621);
|
|
152
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models[1].id).toEqual(709);
|
|
153
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models[2].id).toEqual(797);
|
|
154
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models[3].id).toEqual(885);
|
|
155
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models[4].id).toEqual(973);
|
|
156
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models[5].id).toEqual(1061);
|
|
157
|
+
expect(first === null || first === void 0 ? void 0 : first.actualProductVariant.productVariants.models[0].productVariantImages.models[6].id).toEqual(1149);
|
|
158
|
+
const second = inventoryLevels === null || inventoryLevels === void 0 ? void 0 : inventoryLevels.models[1];
|
|
159
|
+
expect(second === null || second === void 0 ? void 0 : second.id).toEqual(35);
|
|
160
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.id).toEqual(125);
|
|
161
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models.length).toEqual(1);
|
|
162
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].actualProductVariantId).toEqual(125);
|
|
163
|
+
// I think the above test is good enough, and not sure I actual care about below
|
|
164
|
+
// expect(second.actualProductVariant.productVariants.models[0].actualProductVariant.id).toEqual(125);
|
|
165
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].id).toEqual(209);
|
|
166
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].color.id).toEqual(1);
|
|
167
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].gender.id).toEqual(1);
|
|
168
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].product.id).toEqual(1);
|
|
169
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].size.id).toEqual(9);
|
|
170
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models.length).toEqual(7);
|
|
171
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models[0].id).toEqual(679);
|
|
172
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models[1].id).toEqual(767);
|
|
173
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models[2].id).toEqual(855);
|
|
174
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models[3].id).toEqual(943);
|
|
175
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models[4].id).toEqual(1031);
|
|
176
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models[5].id).toEqual(1119);
|
|
177
|
+
expect(second === null || second === void 0 ? void 0 : second.actualProductVariant.productVariants.models[0].productVariantImages.models[6].id).toEqual(1207);
|
|
178
|
+
});
|
|
179
|
+
// Test for a nested object (eg, parcel) with objects in it that referenced to
|
|
180
|
+
// it (eg, parcel_events), correctly placing the objects (parcel_events) in
|
|
181
|
+
// its (parcel) collection of models, and not errantly placing the established
|
|
182
|
+
// parent node (parcel) as a direct reference of the child (parcel_event).
|
|
183
|
+
// For example: the errant behavior was:
|
|
184
|
+
// Parcel1
|
|
185
|
+
// ParcelEvent1
|
|
186
|
+
// Parcel1
|
|
187
|
+
// ParcelEvent2
|
|
188
|
+
// Instead of:
|
|
189
|
+
// Parcel1
|
|
190
|
+
// ParcelEvent1
|
|
191
|
+
// ParcelEvent2
|
|
192
|
+
// NOTE: if this test ever breaks, you can widdle the five.json file to just
|
|
193
|
+
// the two relevant line items of the one relevant order. This test should
|
|
194
|
+
// be doing that, but since code coverage all-around isn't great and I already
|
|
195
|
+
// had this fuller json dump from production, I just used it all - YOLO.
|
|
196
|
+
test('a deeply nested models property was misbehaving', () => {
|
|
197
|
+
const core = (0, core_1.createCore)({ entities: entities_5.entities });
|
|
198
|
+
const orders = core.createFromDatabase(five);
|
|
199
|
+
// The assertion that failed when the bug was present
|
|
200
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(2);
|
|
201
|
+
// Lots of other assertions that are unrelated and shouldn't be here except
|
|
202
|
+
// I'm insecure about the lack of tests so just going at it cause I can.
|
|
203
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].id).toEqual(14219);
|
|
204
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].email).toEqual('tswift@kujo.com');
|
|
205
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models.length).toEqual(2);
|
|
206
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].id).toEqual(17298);
|
|
207
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].orderId).toEqual(14219);
|
|
208
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].id).toEqual(17297);
|
|
209
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].orderId).toEqual(14219);
|
|
210
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models.length).toEqual(1);
|
|
211
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].id).toEqual(1);
|
|
212
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcelId).toEqual(1);
|
|
213
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].lineItemId).toEqual(17297);
|
|
214
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.id).toEqual(1);
|
|
215
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(2);
|
|
216
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(3);
|
|
217
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[0].parcelId).toEqual(1);
|
|
218
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[0].status).toEqual('in_transit');
|
|
219
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[1].id).toEqual(1);
|
|
220
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[1].parcelId).toEqual(1);
|
|
221
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[1].status).toEqual('placed');
|
|
222
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].id).toEqual(13888);
|
|
223
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].email).toEqual('tswift@kujo.com');
|
|
224
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models.length).toEqual(1);
|
|
225
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].id).toEqual(16900);
|
|
226
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].orderId).toEqual(13888);
|
|
227
|
+
});
|
|
228
|
+
// Problem:
|
|
229
|
+
// Parcel
|
|
230
|
+
// ParcelLineItem
|
|
231
|
+
// LineItem
|
|
232
|
+
// Order
|
|
233
|
+
// Customer
|
|
234
|
+
// ParcelLineItem
|
|
235
|
+
// LineItem
|
|
236
|
+
// [MISSING ORDER]
|
|
237
|
+
// Issue occcurs in nestClump
|
|
238
|
+
// Problem only surfaced when custom was included
|
|
239
|
+
test('a deeply nested models property was misbehaving', () => {
|
|
240
|
+
const core = (0, core_1.createCore)({ entities: entities_6.entities });
|
|
241
|
+
const parcels = core.createFromDatabase(six);
|
|
242
|
+
expect(parcels.models.length).toEqual(1);
|
|
243
|
+
const parcel = parcels.models[0];
|
|
244
|
+
// The assertion that failed when the bug was present
|
|
245
|
+
expect(parcel.parcelLineItems.models[1].lineItem.order).toBeDefined();
|
|
246
|
+
// Lots of other assertions that are unrelated and shouldn't be here except
|
|
247
|
+
// I'm insecure about the lack of tests so just going at it cause I can.
|
|
248
|
+
expect(parcel.id).toEqual(1);
|
|
249
|
+
expect(parcel.parcelLineItems.models.length).toEqual(2);
|
|
250
|
+
expect(parcel.parcelLineItems.models[0].id).toEqual(604);
|
|
251
|
+
expect(parcel.parcelLineItems.models[0].lineItem.id).toEqual(17298);
|
|
252
|
+
expect(parcel.parcelLineItems.models[0].lineItem.order.id).toEqual(14219);
|
|
253
|
+
expect(parcel.parcelLineItems.models[0].lineItem.order.customer.id).toEqual(5390);
|
|
254
|
+
expect(parcel.parcelLineItems.models[0].lineItem.order.customer.email).toEqual('tswift@kujo.com');
|
|
255
|
+
expect(parcel.parcelLineItems.models[1].id).toEqual(605);
|
|
256
|
+
expect(parcel.parcelLineItems.models[1].lineItem.id).toEqual(17297);
|
|
257
|
+
expect(parcel.parcelLineItems.models[1].lineItem.order.id).toEqual(14219);
|
|
258
|
+
expect(parcel.parcelLineItems.models[1].lineItem.order.customer.id).toEqual(5390);
|
|
259
|
+
expect(parcel.parcelLineItems.models[1].lineItem.order.customer.email).toEqual('tswift@kujo.com');
|
|
260
|
+
});
|
|
261
|
+
// Problem:
|
|
262
|
+
// InventoryLevel
|
|
263
|
+
// ActualProductVariant
|
|
264
|
+
// ProductVariant(1)
|
|
265
|
+
// Color
|
|
266
|
+
// ProductVariant(2)
|
|
267
|
+
// Instead of:
|
|
268
|
+
// InventoryLevel
|
|
269
|
+
// ActualProductVariant
|
|
270
|
+
// ProductVariant
|
|
271
|
+
// Color
|
|
272
|
+
// ProductVariant(2)
|
|
273
|
+
// Color
|
|
274
|
+
// Issue occcurs in nestClump
|
|
275
|
+
test('a deeply nested models property was attaching to wrong parent', () => {
|
|
276
|
+
const core = (0, core_1.createCore)({ entities: entities_3.entities });
|
|
277
|
+
const inventoryLevels = core.createFromDatabase(seven);
|
|
278
|
+
expect(inventoryLevels.models.length).toEqual(1);
|
|
279
|
+
const inventoryLevel = inventoryLevels.models[0];
|
|
280
|
+
// The assertion that failed when the bug was present
|
|
281
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[1]).toBeDefined();
|
|
282
|
+
// Lots of other assertions that are unrelated and shouldn't be here except
|
|
283
|
+
// I'm insecure about the lack of tests so just going at it cause I can.
|
|
284
|
+
expect(inventoryLevel.id).toEqual(30);
|
|
285
|
+
expect(inventoryLevel.actualProductVariant.id).toEqual(15);
|
|
286
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models.length).toEqual(2);
|
|
287
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[0].id).toEqual(179);
|
|
288
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[0].color.id).toEqual(4);
|
|
289
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[0].gender.id).toEqual(1);
|
|
290
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[0].size.id).toEqual(8);
|
|
291
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[1].id).toEqual(180);
|
|
292
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[1].color.id).toEqual(4);
|
|
293
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[1].gender.id).toEqual(2);
|
|
294
|
+
expect(inventoryLevel.actualProductVariant.productVariants.models[1].size.id).toEqual(11);
|
|
295
|
+
});
|
|
296
|
+
// Problem:
|
|
297
|
+
// Shipment
|
|
298
|
+
// ShipmentActualProductVariant
|
|
299
|
+
// ActualProductVariant
|
|
300
|
+
// ProductVariant(1)
|
|
301
|
+
// Product
|
|
302
|
+
// ProductVariant(2)
|
|
303
|
+
// ShipmentActualProductVariant
|
|
304
|
+
// ActualProductVariant
|
|
305
|
+
// Instead of:
|
|
306
|
+
// Shipment
|
|
307
|
+
// ShipmentActualProductVariant
|
|
308
|
+
// ActualProductVariant
|
|
309
|
+
// ProductVariant(1)
|
|
310
|
+
// Product
|
|
311
|
+
// ShipmentActualProductVariant
|
|
312
|
+
// ActualProductVariant
|
|
313
|
+
// ProductVariant(2)
|
|
314
|
+
// Product
|
|
315
|
+
// Issue occcurs in nestClump
|
|
316
|
+
test('a deeply nested models property was attaching to wrong parent 2', () => {
|
|
317
|
+
const core = (0, core_1.createCore)({ entities: entities_3.entities });
|
|
318
|
+
const shipments = core.createFromDatabase(eight);
|
|
319
|
+
// The assertion that failed when the bug was present
|
|
320
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants).toBeDefined();
|
|
321
|
+
// IN ADDITION TO ABOVE ASSERTION and helpful test description of what is
|
|
322
|
+
// being tested, the below tests tease out some logic that was hitherto
|
|
323
|
+
// incorrect. This "some logic" should be defined and have separate tests
|
|
324
|
+
// and jazz, but my brain hurts so TLDR these below tests are important but
|
|
325
|
+
// (somewhat?) unrelated to the example/assertion above. "Are you serious?!"
|
|
326
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models.length).toEqual(2);
|
|
327
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].id).toEqual(19);
|
|
328
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models.length).toEqual(2);
|
|
329
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].id).toEqual(25);
|
|
330
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.id).toEqual(65);
|
|
331
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models.length).toEqual(2);
|
|
332
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].id).toEqual(310);
|
|
333
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].product.id).toEqual(1);
|
|
334
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].size.id).toEqual(1);
|
|
335
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].color.id).toEqual(1);
|
|
336
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].gender.id).toEqual(1);
|
|
337
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].id).toEqual(309);
|
|
338
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].product.id).toEqual(2);
|
|
339
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].size.id).toEqual(4);
|
|
340
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].color.id).toEqual(1);
|
|
341
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].gender.id).toEqual(2);
|
|
342
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].id).toEqual(26);
|
|
343
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.id).toEqual(25);
|
|
344
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models.length).toEqual(2);
|
|
345
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[0].id).toEqual(194);
|
|
346
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[0].product.id).toEqual(1);
|
|
347
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[0].size.id).toEqual(2);
|
|
348
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[0].color.id).toEqual(1);
|
|
349
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[0].gender.id).toEqual(1);
|
|
350
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[1].id).toEqual(195);
|
|
351
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[1].product.id).toEqual(2);
|
|
352
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[1].size.id).toEqual(5);
|
|
353
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[1].color.id).toEqual(1);
|
|
354
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[0].shipmentActualProductVariants.models[1].actualProductVariant.productVariants.models[1].gender.id).toEqual(2);
|
|
355
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].id).toEqual(18);
|
|
356
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models.length).toEqual(1);
|
|
357
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].id).toEqual(1);
|
|
358
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.id).toEqual(25);
|
|
359
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models.length).toEqual(2);
|
|
360
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].id).toEqual(194);
|
|
361
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].product.id).toEqual(1);
|
|
362
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].size.id).toEqual(2);
|
|
363
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].color.id).toEqual(1);
|
|
364
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[0].gender.id).toEqual(1);
|
|
365
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].id).toEqual(195);
|
|
366
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].product.id).toEqual(2);
|
|
367
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].size.id).toEqual(5);
|
|
368
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].color.id).toEqual(1);
|
|
369
|
+
expect(shipments === null || shipments === void 0 ? void 0 : shipments.models[1].shipmentActualProductVariants.models[0].actualProductVariant.productVariants.models[1].gender.id).toEqual(2);
|
|
370
|
+
});
|
|
371
|
+
// Issue occcurs in nestClump
|
|
372
|
+
// Problem is with only top level nodes
|
|
373
|
+
test('just top level nodes', () => {
|
|
374
|
+
const core = (0, core_1.createCore)({ entities: entities_4.entities });
|
|
375
|
+
let featureSwitches;
|
|
376
|
+
try {
|
|
377
|
+
// This failed when the bug was present
|
|
378
|
+
featureSwitches = core.createFromDatabase(nine);
|
|
379
|
+
}
|
|
380
|
+
catch (e) {
|
|
381
|
+
expect(e).not.toBeDefined();
|
|
382
|
+
}
|
|
383
|
+
expect(featureSwitches).toBeDefined();
|
|
384
|
+
// Lots of other assertions that are unrelated and shouldn't be here except
|
|
385
|
+
// I'm insecure about the lack of tests so just going at it cause I can.
|
|
386
|
+
expect(featureSwitches === null || featureSwitches === void 0 ? void 0 : featureSwitches.models.length).toEqual(2);
|
|
387
|
+
expect(featureSwitches === null || featureSwitches === void 0 ? void 0 : featureSwitches.models[0].id).toEqual('google_one_tap_sign_in');
|
|
388
|
+
expect(featureSwitches === null || featureSwitches === void 0 ? void 0 : featureSwitches.models[1].id).toEqual('website_live_chat');
|
|
389
|
+
});
|
|
390
|
+
// Issue occcurs in nestClump
|
|
391
|
+
// Problem is when oldest parent is an empty join record and is not included
|
|
392
|
+
// which results in the oldest parent search returning -1 and parent heirarchy
|
|
393
|
+
// is thus messed up.
|
|
394
|
+
test('10', () => {
|
|
395
|
+
const core = (0, core_1.createCore)({ entities: entities_3.entities });
|
|
396
|
+
let orders;
|
|
397
|
+
try {
|
|
398
|
+
// This failed when the bug was present
|
|
399
|
+
orders = core.createFromDatabase(ten);
|
|
400
|
+
}
|
|
401
|
+
catch (e) {
|
|
402
|
+
expect(e).not.toBeDefined();
|
|
403
|
+
}
|
|
404
|
+
expect(orders).toBeDefined();
|
|
405
|
+
// Lots of other assertions that are unrelated and shouldn't be here except
|
|
406
|
+
// I'm insecure about the lack of tests so just going at it cause I can.
|
|
407
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models.length).toEqual(5);
|
|
408
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].id).toEqual(24591);
|
|
409
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].customer.id).toEqual(5390);
|
|
410
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].physicalAddress.id).toEqual(48982);
|
|
411
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models.length).toEqual(1);
|
|
412
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].id).toEqual(29883);
|
|
413
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.id).toEqual(158);
|
|
414
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.product.id).toEqual(1);
|
|
415
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.size.id).toEqual(9);
|
|
416
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.color.id).toEqual(3);
|
|
417
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
418
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
419
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(17);
|
|
420
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models.length).toEqual(1);
|
|
421
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].id).toEqual(6100);
|
|
422
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.id).toEqual(5942);
|
|
423
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(14);
|
|
424
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(193775);
|
|
425
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[1].id).toEqual(193774);
|
|
426
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[2].id).toEqual(193773);
|
|
427
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[3].id).toEqual(193425);
|
|
428
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[4].id).toEqual(193424);
|
|
429
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[5].id).toEqual(193423);
|
|
430
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[6].id).toEqual(192713);
|
|
431
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[7].id).toEqual(192712);
|
|
432
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[8].id).toEqual(192711);
|
|
433
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[9].id).toEqual(192709);
|
|
434
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[10].id).toEqual(192171);
|
|
435
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[11].id).toEqual(192170);
|
|
436
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[12].id).toEqual(192169);
|
|
437
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[13].id).toEqual(191790);
|
|
438
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].id).toEqual(24589);
|
|
439
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].customer.id).toEqual(5390);
|
|
440
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].physicalAddress.id).toEqual(48982);
|
|
441
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models.length).toEqual(1);
|
|
442
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].id).toEqual(29880);
|
|
443
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.id).toEqual(158);
|
|
444
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.product.id).toEqual(1);
|
|
445
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.size.id).toEqual(9);
|
|
446
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.color.id).toEqual(3);
|
|
447
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
448
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
449
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(17);
|
|
450
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].id).toEqual(24587);
|
|
451
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].customer.id).toEqual(5390);
|
|
452
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].physicalAddress.id).toEqual(28145);
|
|
453
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models.length).toEqual(1);
|
|
454
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].id).toEqual(29877);
|
|
455
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.id).toEqual(158);
|
|
456
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.product.id).toEqual(1);
|
|
457
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.size.id).toEqual(9);
|
|
458
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.color.id).toEqual(3);
|
|
459
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
460
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
461
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(17);
|
|
462
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models.length).toEqual(1);
|
|
463
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].id).toEqual(6070);
|
|
464
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].parcel.id).toEqual(5914);
|
|
465
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(1);
|
|
466
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(189194);
|
|
467
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].id).toEqual(14219);
|
|
468
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].customer.id).toEqual(5390);
|
|
469
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].physicalAddress.id).toEqual(28145);
|
|
470
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models.length).toEqual(2);
|
|
471
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].id).toEqual(17298);
|
|
472
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.id).toEqual(353);
|
|
473
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.product.id).toEqual(8);
|
|
474
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.size.id).toEqual(20);
|
|
475
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.color.id).toEqual(10);
|
|
476
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.gender.id).toEqual(3);
|
|
477
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
478
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(789);
|
|
479
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models.length).toEqual(1);
|
|
480
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].id).toEqual(3338);
|
|
481
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.id).toEqual(3304);
|
|
482
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(3);
|
|
483
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(87279);
|
|
484
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[1].id).toEqual(87278);
|
|
485
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[2].id).toEqual(84361);
|
|
486
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].id).toEqual(17297);
|
|
487
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.id).toEqual(344);
|
|
488
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.product.id).toEqual(6);
|
|
489
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.size.id).toEqual(22);
|
|
490
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.color.id).toEqual(8);
|
|
491
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.gender.id).toEqual(3);
|
|
492
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.productVariantImages.models.length).toEqual(1);
|
|
493
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.productVariantImages.models[0].id).toEqual(780);
|
|
494
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models.length).toEqual(1);
|
|
495
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].id).toEqual(2311);
|
|
496
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.id).toEqual(2317);
|
|
497
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(3);
|
|
498
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(52627);
|
|
499
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[1].id).toEqual(52626);
|
|
500
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[2].id).toEqual(48326);
|
|
501
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].id).toEqual(13888);
|
|
502
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].customer.id).toEqual(5390);
|
|
503
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].physicalAddress.id).toEqual(7608);
|
|
504
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models.length).toEqual(1);
|
|
505
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].id).toEqual(16900);
|
|
506
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.id).toEqual(363);
|
|
507
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.product.id).toEqual(5);
|
|
508
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.size.id).toEqual(8);
|
|
509
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.color.id).toEqual(12);
|
|
510
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
511
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
512
|
+
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(829);
|
|
513
|
+
});
|
|
514
|
+
// Issue occcurs in nestClump
|
|
515
|
+
// Problem from early returning not logging bo so parent hierarcy was missing it
|
|
516
|
+
test('11', () => {
|
|
517
|
+
const core = (0, core_1.createCore)({ entities: entities_3.entities });
|
|
518
|
+
let orders;
|
|
519
|
+
try {
|
|
520
|
+
// This failed when the bug was present
|
|
521
|
+
orders = core.createFromDatabase(eleven);
|
|
522
|
+
}
|
|
523
|
+
catch (e) {
|
|
524
|
+
expect(e).not.toBeDefined();
|
|
525
|
+
}
|
|
526
|
+
expect(orders).toBeDefined();
|
|
527
|
+
});
|
|
528
|
+
// Issue occcurs in nestClump
|
|
529
|
+
// Problem when a table references another model twice (two columns)
|
|
530
|
+
test('12', () => {
|
|
531
|
+
const core = (0, core_1.createCore)({ entities: entities_7.entities });
|
|
532
|
+
let prompt;
|
|
533
|
+
try {
|
|
534
|
+
// This failed when the bug was present
|
|
535
|
+
prompt = core.createFromDatabase(twelve);
|
|
536
|
+
}
|
|
537
|
+
catch (e) {
|
|
538
|
+
expect(e).not.toBeDefined();
|
|
539
|
+
}
|
|
540
|
+
expect(prompt).toBeDefined();
|
|
541
|
+
// Ideally the below should work
|
|
542
|
+
// expect(prompt.fromMember.id).toEqual(1);
|
|
543
|
+
});
|
|
544
|
+
// Issue occcurs in nestClump
|
|
545
|
+
// Problem when a table has records that are supposed to nest under root
|
|
546
|
+
// but nest under other stuff below it instead
|
|
547
|
+
// Member
|
|
548
|
+
// Recommendations [1]
|
|
549
|
+
// Brand
|
|
550
|
+
// Recommendations [1]
|
|
551
|
+
// Passion
|
|
552
|
+
// Recommendations [2]
|
|
553
|
+
// -- instead of correct --
|
|
554
|
+
// Member
|
|
555
|
+
// Recommendations[4]
|
|
556
|
+
// Brand
|
|
557
|
+
// Passion
|
|
558
|
+
test('13', () => {
|
|
559
|
+
const core = (0, core_1.createCore)({ entities: entities_8.entities });
|
|
560
|
+
const members = core.createFromDatabase(thirteen);
|
|
561
|
+
const member = members === null || members === void 0 ? void 0 : members.models[0];
|
|
562
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models.length).toEqual(4);
|
|
563
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[0].brand.id).toEqual(2);
|
|
564
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[0].product.id).toEqual(7);
|
|
565
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[0].category.id).toEqual(1);
|
|
566
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[0].recommendationAudiences.models[0].audience.id).toEqual(1);
|
|
567
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[1].brand.id).toEqual(2);
|
|
568
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[1].product.id).toEqual(1);
|
|
569
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[1].category.id).toEqual(2);
|
|
570
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[1].recommendationAudiences.models[0].audience.id).toEqual(1);
|
|
571
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[2].brand.id).toEqual(3);
|
|
572
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[2].product.id).toEqual(27);
|
|
573
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[2].category.id).toEqual(3);
|
|
574
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[2].recommendationAudiences.models[0].audience.id).toEqual(1);
|
|
575
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].brand.id).toEqual(6);
|
|
576
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].product.id).toEqual(75);
|
|
577
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].category.id).toEqual(4);
|
|
578
|
+
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].recommendationAudiences.models[0].audience.id).toEqual(1);
|
|
579
|
+
});
|
|
580
|
+
// Issue occcurs in nestClump
|
|
581
|
+
// Problem when a table has two columns which reference the same other table
|
|
582
|
+
test('14', () => {
|
|
583
|
+
var _a;
|
|
584
|
+
const core = (0, core_1.createCore)({ entities: entities_9.entities });
|
|
585
|
+
const persons = core.createFromDatabase(fourteen);
|
|
586
|
+
expect(persons === null || persons === void 0 ? void 0 : persons.models.length).toEqual(1);
|
|
587
|
+
expect(persons.models[0].id).toEqual(67);
|
|
588
|
+
// Known issue: A reference always uses the model's name,
|
|
589
|
+
// instead of some version of the column's name
|
|
590
|
+
expect((_a = persons.models[0].customers) === null || _a === void 0 ? void 0 : _a.models.length).toEqual(1);
|
|
591
|
+
expect(persons.models[0].customers.models[0].id).toEqual(4);
|
|
592
|
+
});
|
|
380
593
|
});
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
expect(
|
|
394
|
-
}
|
|
395
|
-
expect(orders).toBeDefined();
|
|
396
|
-
// Lots of other assertions that are unrelated and shouldn't be here except
|
|
397
|
-
// I'm insecure about the lack of tests so just going at it cause I can.
|
|
398
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models.length).toEqual(5);
|
|
399
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].id).toEqual(24591);
|
|
400
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].customer.id).toEqual(5390);
|
|
401
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].physicalAddress.id).toEqual(48982);
|
|
402
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models.length).toEqual(1);
|
|
403
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].id).toEqual(29883);
|
|
404
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.id).toEqual(158);
|
|
405
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.product.id).toEqual(1);
|
|
406
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.size.id).toEqual(9);
|
|
407
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.color.id).toEqual(3);
|
|
408
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
409
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
410
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(17);
|
|
411
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models.length).toEqual(1);
|
|
412
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].id).toEqual(6100);
|
|
413
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.id).toEqual(5942);
|
|
414
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(14);
|
|
415
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(193775);
|
|
416
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[1].id).toEqual(193774);
|
|
417
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[2].id).toEqual(193773);
|
|
418
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[3].id).toEqual(193425);
|
|
419
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[4].id).toEqual(193424);
|
|
420
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[5].id).toEqual(193423);
|
|
421
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[6].id).toEqual(192713);
|
|
422
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[7].id).toEqual(192712);
|
|
423
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[8].id).toEqual(192711);
|
|
424
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[9].id).toEqual(192709);
|
|
425
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[10].id).toEqual(192171);
|
|
426
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[11].id).toEqual(192170);
|
|
427
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[12].id).toEqual(192169);
|
|
428
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[0].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[13].id).toEqual(191790);
|
|
429
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].id).toEqual(24589);
|
|
430
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].customer.id).toEqual(5390);
|
|
431
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].physicalAddress.id).toEqual(48982);
|
|
432
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models.length).toEqual(1);
|
|
433
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].id).toEqual(29880);
|
|
434
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.id).toEqual(158);
|
|
435
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.product.id).toEqual(1);
|
|
436
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.size.id).toEqual(9);
|
|
437
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.color.id).toEqual(3);
|
|
438
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
439
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
440
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[1].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(17);
|
|
441
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].id).toEqual(24587);
|
|
442
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].customer.id).toEqual(5390);
|
|
443
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].physicalAddress.id).toEqual(28145);
|
|
444
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models.length).toEqual(1);
|
|
445
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].id).toEqual(29877);
|
|
446
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.id).toEqual(158);
|
|
447
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.product.id).toEqual(1);
|
|
448
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.size.id).toEqual(9);
|
|
449
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.color.id).toEqual(3);
|
|
450
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
451
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
452
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(17);
|
|
453
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models.length).toEqual(1);
|
|
454
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].id).toEqual(6070);
|
|
455
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].parcel.id).toEqual(5914);
|
|
456
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(1);
|
|
457
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[2].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(189194);
|
|
458
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].id).toEqual(14219);
|
|
459
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].customer.id).toEqual(5390);
|
|
460
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].physicalAddress.id).toEqual(28145);
|
|
461
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models.length).toEqual(2);
|
|
462
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].id).toEqual(17298);
|
|
463
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.id).toEqual(353);
|
|
464
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.product.id).toEqual(8);
|
|
465
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.size.id).toEqual(20);
|
|
466
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.color.id).toEqual(10);
|
|
467
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.gender.id).toEqual(3);
|
|
468
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
469
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(789);
|
|
470
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models.length).toEqual(1);
|
|
471
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].id).toEqual(3338);
|
|
472
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.id).toEqual(3304);
|
|
473
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(3);
|
|
474
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(87279);
|
|
475
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[1].id).toEqual(87278);
|
|
476
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[0].parcelLineItems.models[0].parcel.parcelEvents.models[2].id).toEqual(84361);
|
|
477
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].id).toEqual(17297);
|
|
478
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.id).toEqual(344);
|
|
479
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.product.id).toEqual(6);
|
|
480
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.size.id).toEqual(22);
|
|
481
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.color.id).toEqual(8);
|
|
482
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.gender.id).toEqual(3);
|
|
483
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.productVariantImages.models.length).toEqual(1);
|
|
484
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].productVariant.productVariantImages.models[0].id).toEqual(780);
|
|
485
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models.length).toEqual(1);
|
|
486
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].id).toEqual(2311);
|
|
487
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.id).toEqual(2317);
|
|
488
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models.length).toEqual(3);
|
|
489
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[0].id).toEqual(52627);
|
|
490
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[1].id).toEqual(52626);
|
|
491
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[3].lineItems.models[1].parcelLineItems.models[0].parcel.parcelEvents.models[2].id).toEqual(48326);
|
|
492
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].id).toEqual(13888);
|
|
493
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].customer.id).toEqual(5390);
|
|
494
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].physicalAddress.id).toEqual(7608);
|
|
495
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models.length).toEqual(1);
|
|
496
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].id).toEqual(16900);
|
|
497
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.id).toEqual(363);
|
|
498
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.product.id).toEqual(5);
|
|
499
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.size.id).toEqual(8);
|
|
500
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.color.id).toEqual(12);
|
|
501
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.gender.id).toEqual(1);
|
|
502
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.productVariantImages.models.length).toEqual(1);
|
|
503
|
-
expect(orders === null || orders === void 0 ? void 0 : orders.models[4].lineItems.models[0].productVariant.productVariantImages.models[0].id).toEqual(829);
|
|
594
|
+
describe('createOneFromDatabase', () => {
|
|
595
|
+
test('reduces to one', () => {
|
|
596
|
+
const core = (0, core_1.createCore)({ entities: entities_1.entities });
|
|
597
|
+
const order = core.createOneFromDatabase(one);
|
|
598
|
+
expect(order instanceof entities_1.entities[0].Model).toBe(true);
|
|
599
|
+
});
|
|
600
|
+
test('throws when less than one', () => {
|
|
601
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
602
|
+
expect(() => core.createOneFromDatabase([])).toThrow();
|
|
603
|
+
});
|
|
604
|
+
test('throws when more than one', () => {
|
|
605
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
606
|
+
expect(() => core.createOneFromDatabase(three)).toThrow();
|
|
607
|
+
});
|
|
504
608
|
});
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
609
|
+
describe('createOneOrNoneFromDatabase', () => {
|
|
610
|
+
test('reduces to one', () => {
|
|
611
|
+
const core = (0, core_1.createCore)({ entities: entities_1.entities });
|
|
612
|
+
const order = core.createOneOrNoneFromDatabase(one);
|
|
613
|
+
expect(order instanceof entities_1.entities[0].Model).toBe(true);
|
|
614
|
+
});
|
|
615
|
+
test('returns undefined when less than one', () => {
|
|
616
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
617
|
+
expect(core.createOneOrNoneFromDatabase([])).toEqual(void 0);
|
|
618
|
+
});
|
|
619
|
+
test('throws when more than one', () => {
|
|
620
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
621
|
+
expect(() => core.createOneOrNoneFromDatabase(three)).toThrow();
|
|
622
|
+
});
|
|
518
623
|
});
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
expect(
|
|
530
|
-
}
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
624
|
+
describe('createManyFromDatabase', () => {
|
|
625
|
+
test('one result', () => {
|
|
626
|
+
const core = (0, core_1.createCore)({ entities: entities_1.entities });
|
|
627
|
+
const orders = core.createManyFromDatabase(one);
|
|
628
|
+
expect(orders instanceof entities_1.entities[0].Collection).toBe(true);
|
|
629
|
+
expect(Array.isArray(orders.models)).toBe(true);
|
|
630
|
+
expect(orders.models.length).toEqual(1);
|
|
631
|
+
});
|
|
632
|
+
test('throws when less than one', () => {
|
|
633
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
634
|
+
expect(() => core.createManyFromDatabase([])).toThrow();
|
|
635
|
+
});
|
|
636
|
+
test('more than one', () => {
|
|
637
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
638
|
+
const articles = core.createManyFromDatabase(three);
|
|
639
|
+
expect(articles instanceof entities_2.entities[0].Collection).toBe(true);
|
|
640
|
+
expect(Array.isArray(articles.models)).toBe(true);
|
|
641
|
+
expect(articles.models.length).toEqual(2);
|
|
642
|
+
});
|
|
534
643
|
});
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[2].category.id).toEqual(3);
|
|
565
|
-
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[2].recommendationAudiences.models[0].audience.id).toEqual(1);
|
|
566
|
-
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].brand.id).toEqual(6);
|
|
567
|
-
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].product.id).toEqual(75);
|
|
568
|
-
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].category.id).toEqual(4);
|
|
569
|
-
expect(member === null || member === void 0 ? void 0 : member.recommendations.models[3].recommendationAudiences.models[0].audience.id).toEqual(1);
|
|
644
|
+
describe('createAnyFromDatabase', () => {
|
|
645
|
+
test('one result', () => {
|
|
646
|
+
const core = (0, core_1.createCore)({ entities: entities_1.entities });
|
|
647
|
+
const orders = core.createAnyFromDatabase(one, entities_1.entities[0].Model);
|
|
648
|
+
expect(orders instanceof entities_1.entities[0].Collection).toBe(true);
|
|
649
|
+
expect(Array.isArray(orders.models)).toBe(true);
|
|
650
|
+
expect(orders.models.length).toEqual(1);
|
|
651
|
+
});
|
|
652
|
+
test('less than one using table name', () => {
|
|
653
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
654
|
+
const articles = core.createAnyFromDatabase([], entities_2.entities[0].tableName);
|
|
655
|
+
expect(articles instanceof entities_2.entities[0].Collection).toBe(true);
|
|
656
|
+
expect(Array.isArray(articles.models)).toBe(true);
|
|
657
|
+
expect(articles.models.length).toEqual(0);
|
|
658
|
+
});
|
|
659
|
+
test('less than one using model class', () => {
|
|
660
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
661
|
+
const articles = core.createAnyFromDatabase([], entities_2.entities[0].Model);
|
|
662
|
+
expect(articles instanceof entities_2.entities[0].Collection).toBe(true);
|
|
663
|
+
expect(Array.isArray(articles.models)).toBe(true);
|
|
664
|
+
expect(articles.models.length).toEqual(0);
|
|
665
|
+
});
|
|
666
|
+
test('more than one', () => {
|
|
667
|
+
const core = (0, core_1.createCore)({ entities: entities_2.entities });
|
|
668
|
+
const articles = core.createAnyFromDatabase(three, entities_2.entities[0].Model);
|
|
669
|
+
expect(articles instanceof entities_2.entities[0].Collection).toBe(true);
|
|
670
|
+
expect(Array.isArray(articles.models)).toBe(true);
|
|
671
|
+
expect(articles.models.length).toEqual(2);
|
|
672
|
+
});
|
|
570
673
|
});
|
|
571
|
-
test('
|
|
674
|
+
test('tables', () => {
|
|
572
675
|
const core = (0, core_1.createCore)({ entities: entities_1.entities });
|
|
573
676
|
expect(Object.keys(core.tables).length).toEqual(5);
|
|
574
677
|
expect(core.tables.utmSource.columns).toEqual('"utm_source".id as "utm_source#id", "utm_source".value as "utm_source#value", "utm_source".label as "utm_source#label", "utm_source".internal as "utm_source#internal"');
|