@loopback/repository-tests 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.js +170 -0
- package/dist/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.js +55 -0
- package/dist/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.js +170 -0
- package/dist/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.js +361 -0
- package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.js +161 -0
- package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.d.ts +2 -0
- package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.js +190 -0
- package/dist/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.js.map +1 -0
- package/dist/crud/relations/fixtures/models/contact.model.d.ts +18 -0
- package/dist/crud/relations/fixtures/models/contact.model.js +49 -0
- package/dist/crud/relations/fixtures/models/contact.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/customer-promotion-link.model.d.ts +14 -0
- package/dist/crud/relations/fixtures/models/customer-promotion-link.model.js +46 -0
- package/dist/crud/relations/fixtures/models/customer-promotion-link.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/customer.model.d.ts +16 -3
- package/dist/crud/relations/fixtures/models/customer.model.js +27 -9
- package/dist/crud/relations/fixtures/models/customer.model.js.map +1 -1
- package/dist/crud/relations/fixtures/models/index.d.ts +6 -0
- package/dist/crud/relations/fixtures/models/index.js +6 -0
- package/dist/crud/relations/fixtures/models/index.js.map +1 -1
- package/dist/crud/relations/fixtures/models/payment-method.model.d.ts +47 -0
- package/dist/crud/relations/fixtures/models/payment-method.model.js +87 -0
- package/dist/crud/relations/fixtures/models/payment-method.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/promotion.model.d.ts +27 -0
- package/dist/crud/relations/fixtures/models/promotion.model.js +54 -0
- package/dist/crud/relations/fixtures/models/promotion.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/stakeholder.model.d.ts +7 -0
- package/dist/crud/relations/fixtures/models/stakeholder.model.js +38 -0
- package/dist/crud/relations/fixtures/models/stakeholder.model.js.map +1 -0
- package/dist/crud/relations/fixtures/models/supplier.model.d.ts +15 -0
- package/dist/crud/relations/fixtures/models/supplier.model.js +23 -0
- package/dist/crud/relations/fixtures/models/supplier.model.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/contact.repository.d.ts +30 -0
- package/dist/crud/relations/fixtures/repositories/contact.repository.js +21 -0
- package/dist/crud/relations/fixtures/repositories/contact.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.d.ts +26 -0
- package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.js +18 -0
- package/dist/crud/relations/fixtures/repositories/customer-promotion-link.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/customer.repository.d.ts +9 -2
- package/dist/crud/relations/fixtures/repositories/customer.repository.js +7 -1
- package/dist/crud/relations/fixtures/repositories/customer.repository.js.map +1 -1
- package/dist/crud/relations/fixtures/repositories/index.d.ts +6 -1
- package/dist/crud/relations/fixtures/repositories/index.js +6 -1
- package/dist/crud/relations/fixtures/repositories/index.js.map +1 -1
- package/dist/crud/relations/fixtures/repositories/payment-method.repository.d.ts +77 -0
- package/dist/crud/relations/fixtures/repositories/payment-method.repository.js +45 -0
- package/dist/crud/relations/fixtures/repositories/payment-method.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/promotion.repository.d.ts +49 -0
- package/dist/crud/relations/fixtures/repositories/promotion.repository.js +25 -0
- package/dist/crud/relations/fixtures/repositories/promotion.repository.js.map +1 -0
- package/dist/crud/relations/fixtures/repositories/supplier.repository.d.ts +28 -0
- package/dist/crud/relations/fixtures/repositories/supplier.repository.js +21 -0
- package/dist/crud/relations/fixtures/repositories/supplier.repository.js.map +1 -0
- package/dist/crud/relations/helpers.d.ts +9 -1
- package/dist/crud/relations/helpers.js +85 -10
- package/dist/crud/relations/helpers.js.map +1 -1
- package/dist/helpers.repository-tests.d.ts +1 -1
- package/dist/helpers.repository-tests.js.map +1 -1
- package/package.json +12 -12
- package/src/crud/relations/acceptance/belongs-to.inclusion-resolver.polymorphic.relation.acceptance.ts +221 -0
- package/src/crud/relations/acceptance/belongs-to.polymorphic.relation.acceptance.ts +88 -0
- package/src/crud/relations/acceptance/has-many-through-inclusion-resolver.polymorphic.acceptance.ts +255 -0
- package/src/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.ts +494 -0
- package/src/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.ts +208 -0
- package/src/crud/relations/acceptance/has-one.relation.polymorphic.acceptance.ts +328 -0
- package/src/crud/relations/fixtures/models/contact.model.ts +56 -0
- package/src/crud/relations/fixtures/models/customer-promotion-link.model.ts +52 -0
- package/src/crud/relations/fixtures/models/customer.model.ts +39 -9
- package/src/crud/relations/fixtures/models/index.ts +6 -0
- package/src/crud/relations/fixtures/models/payment-method.model.ts +118 -0
- package/src/crud/relations/fixtures/models/promotion.model.ts +67 -0
- package/src/crud/relations/fixtures/models/stakeholder.model.ts +33 -0
- package/src/crud/relations/fixtures/models/supplier.model.ts +35 -0
- package/src/crud/relations/fixtures/repositories/contact.repository.ts +44 -0
- package/src/crud/relations/fixtures/repositories/customer-promotion-link.repository.ts +20 -0
- package/src/crud/relations/fixtures/repositories/customer.repository.ts +47 -0
- package/src/crud/relations/fixtures/repositories/index.ts +6 -1
- package/src/crud/relations/fixtures/repositories/payment-method.repository.ts +118 -0
- package/src/crud/relations/fixtures/repositories/promotion.repository.ts +37 -0
- package/src/crud/relations/fixtures/repositories/supplier.repository.ts +40 -0
- package/src/crud/relations/helpers.ts +200 -30
- package/src/helpers.repository-tests.ts +1 -1
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright IBM Corp. 2020. All Rights Reserved.
|
|
3
|
+
// Node module: @loopback/repository-tests
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.hasManyThroughRelationAcceptance = void 0;
|
|
8
|
+
const testlab_1 = require("@loopback/testlab");
|
|
9
|
+
const helpers_repository_tests_1 = require("../../../helpers.repository-tests");
|
|
10
|
+
const models_1 = require("../fixtures/models");
|
|
11
|
+
const helpers_1 = require("../helpers");
|
|
12
|
+
function hasManyThroughRelationAcceptance(dataSourceOptions, repositoryClass, features) {
|
|
13
|
+
describe('HasManyThrough relation polymorphic (acceptance)', () => {
|
|
14
|
+
before(helpers_repository_tests_1.deleteAllModelsInDefaultDataSource);
|
|
15
|
+
let customerRepo;
|
|
16
|
+
let freeDeliveryRepo;
|
|
17
|
+
let halfPriceRepo;
|
|
18
|
+
let customerPromotionLinkRepo;
|
|
19
|
+
let existingCustomerId;
|
|
20
|
+
before((0, helpers_repository_tests_1.withCrudCtx)(async function setupRepository(ctx) {
|
|
21
|
+
({
|
|
22
|
+
customerRepo,
|
|
23
|
+
freeDeliveryRepo,
|
|
24
|
+
halfPriceRepo,
|
|
25
|
+
customerPromotionLinkRepo,
|
|
26
|
+
} = (0, helpers_1.givenBoundCrudRepositories)(ctx.dataSource, repositoryClass, features));
|
|
27
|
+
await ctx.dataSource.automigrate([
|
|
28
|
+
models_1.Customer.name,
|
|
29
|
+
models_1.FreeDelivery.name,
|
|
30
|
+
models_1.HalfPrice.name,
|
|
31
|
+
models_1.CustomerPromotionLink.name,
|
|
32
|
+
]);
|
|
33
|
+
}));
|
|
34
|
+
beforeEach(async () => {
|
|
35
|
+
await customerRepo.deleteAll();
|
|
36
|
+
await freeDeliveryRepo.deleteAll();
|
|
37
|
+
await halfPriceRepo.deleteAll();
|
|
38
|
+
await customerPromotionLinkRepo.deleteAll();
|
|
39
|
+
});
|
|
40
|
+
beforeEach(async () => {
|
|
41
|
+
existingCustomerId = (await givenPersistedCustomerInstance()).id;
|
|
42
|
+
});
|
|
43
|
+
it('creates an instance of the related model alone with a through model', async () => {
|
|
44
|
+
const promo = await customerRepo.promotions(existingCustomerId).create({ description: 'free delivery promo' }, {
|
|
45
|
+
throughData: {
|
|
46
|
+
description: 'a through model',
|
|
47
|
+
promotiontype: 'FreeDelivery',
|
|
48
|
+
},
|
|
49
|
+
polymorphicType: 'FreeDelivery',
|
|
50
|
+
});
|
|
51
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(promo)).containDeep((0, testlab_1.toJSON)({
|
|
52
|
+
id: promo.id,
|
|
53
|
+
description: 'free delivery promo',
|
|
54
|
+
}));
|
|
55
|
+
const persistedPromo = await freeDeliveryRepo.findById(promo.id);
|
|
56
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(persistedPromo)).to.deepEqual((0, testlab_1.toJSON)(promo));
|
|
57
|
+
const persistedLink = await customerPromotionLinkRepo.find();
|
|
58
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(persistedLink[0])).to.containDeep((0, testlab_1.toJSON)({
|
|
59
|
+
customerId: existingCustomerId,
|
|
60
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
61
|
+
promotion_id: promo.id,
|
|
62
|
+
description: 'a through model',
|
|
63
|
+
}));
|
|
64
|
+
});
|
|
65
|
+
it('finds instances of the related model', async () => {
|
|
66
|
+
const freeDelivery = await customerRepo
|
|
67
|
+
.promotions(existingCustomerId)
|
|
68
|
+
.create({ description: 'free delivery promo' }, {
|
|
69
|
+
throughData: {
|
|
70
|
+
description: 'a through model',
|
|
71
|
+
promotiontype: 'FreeDelivery',
|
|
72
|
+
},
|
|
73
|
+
polymorphicType: 'FreeDelivery',
|
|
74
|
+
});
|
|
75
|
+
const notMyPromo = await freeDeliveryRepo.create({
|
|
76
|
+
description: "someone else's promo",
|
|
77
|
+
});
|
|
78
|
+
const notMyPromo2 = await halfPriceRepo.create({
|
|
79
|
+
description: "someone else's promo 2",
|
|
80
|
+
});
|
|
81
|
+
const result = await customerRepo
|
|
82
|
+
.promotions(existingCustomerId)
|
|
83
|
+
.find(undefined, {
|
|
84
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
85
|
+
polymorphicType: ['FreeDelivery'],
|
|
86
|
+
});
|
|
87
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result)).to.containDeep((0, testlab_1.toJSON)([freeDelivery]));
|
|
88
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result[0])).to.not.containEql((0, testlab_1.toJSON)(notMyPromo));
|
|
89
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result[0])).to.not.containEql((0, testlab_1.toJSON)(notMyPromo2));
|
|
90
|
+
});
|
|
91
|
+
it('patches instances', async () => {
|
|
92
|
+
const promo1 = await customerRepo.promotions(existingCustomerId).create({ description: 'free delivery promo' }, {
|
|
93
|
+
throughData: {
|
|
94
|
+
description: 'a through model',
|
|
95
|
+
promotiontype: 'FreeDelivery',
|
|
96
|
+
},
|
|
97
|
+
polymorphicType: 'FreeDelivery',
|
|
98
|
+
});
|
|
99
|
+
const promo2 = await customerRepo.promotions(existingCustomerId).create({ description: 'half price promo 2' }, {
|
|
100
|
+
throughData: {
|
|
101
|
+
description: 'a through model',
|
|
102
|
+
promotiontype: 'HalfPrice',
|
|
103
|
+
},
|
|
104
|
+
polymorphicType: 'HalfPrice',
|
|
105
|
+
});
|
|
106
|
+
const promo3 = await customerRepo.promotions(existingCustomerId).create({ description: 'free delivery promo 3' }, {
|
|
107
|
+
throughData: {
|
|
108
|
+
description: 'a through model',
|
|
109
|
+
promotiontype: 'FreeDelivery',
|
|
110
|
+
},
|
|
111
|
+
polymorphicType: 'FreeDelivery',
|
|
112
|
+
});
|
|
113
|
+
const count = await customerRepo.promotions(existingCustomerId).patch({
|
|
114
|
+
FreeDelivery: { description: 'updated free delivery' },
|
|
115
|
+
HalfPrice: { description: 'updated half price' },
|
|
116
|
+
}, undefined, {
|
|
117
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
118
|
+
isPolymorphic: true,
|
|
119
|
+
});
|
|
120
|
+
(0, testlab_1.expect)(count.count).to.equal(3);
|
|
121
|
+
const result = await customerRepo
|
|
122
|
+
.promotions(existingCustomerId)
|
|
123
|
+
.find(undefined, {
|
|
124
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
125
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
126
|
+
});
|
|
127
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result)).to.containDeep((0, testlab_1.toJSON)([
|
|
128
|
+
{ id: promo1.id, description: 'updated free delivery' },
|
|
129
|
+
{ id: promo2.id, description: 'updated half price' },
|
|
130
|
+
{ id: promo3.id, description: 'updated free delivery' },
|
|
131
|
+
]));
|
|
132
|
+
});
|
|
133
|
+
it('patches an instance based on the filter', async () => {
|
|
134
|
+
const promo1 = await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 1' }, {
|
|
135
|
+
throughData: {
|
|
136
|
+
description: 'a through model',
|
|
137
|
+
promotiontype: 'FreeDelivery',
|
|
138
|
+
},
|
|
139
|
+
polymorphicType: 'FreeDelivery',
|
|
140
|
+
});
|
|
141
|
+
const promo2 = await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 2' }, {
|
|
142
|
+
throughData: {
|
|
143
|
+
description: 'a through model',
|
|
144
|
+
promotiontype: 'FreeDelivery',
|
|
145
|
+
},
|
|
146
|
+
polymorphicType: 'FreeDelivery',
|
|
147
|
+
});
|
|
148
|
+
const promo3 = await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 1' }, {
|
|
149
|
+
throughData: {
|
|
150
|
+
description: 'a through model',
|
|
151
|
+
promotiontype: 'HalfPrice',
|
|
152
|
+
},
|
|
153
|
+
polymorphicType: 'HalfPrice',
|
|
154
|
+
});
|
|
155
|
+
const count = await customerRepo.promotions(existingCustomerId).patch({ HalfPrice: { description: 'promo group 2' } }, { id: promo3.id }, {
|
|
156
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
157
|
+
isPolymorphic: true,
|
|
158
|
+
});
|
|
159
|
+
(0, testlab_1.expect)(count.count).to.equal(1);
|
|
160
|
+
const result = await customerRepo
|
|
161
|
+
.promotions(existingCustomerId)
|
|
162
|
+
.find(undefined, {
|
|
163
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
164
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
165
|
+
});
|
|
166
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result)).to.containDeep((0, testlab_1.toJSON)([
|
|
167
|
+
{ id: promo1.id, description: 'promo group 1' },
|
|
168
|
+
{ id: promo2.id, description: 'promo group 2' },
|
|
169
|
+
{ id: promo3.id, description: 'promo group 2' },
|
|
170
|
+
]));
|
|
171
|
+
});
|
|
172
|
+
it('throws error when query tries to change the target id', async () => {
|
|
173
|
+
// a diff id for CartItem instance
|
|
174
|
+
const anotherId = (await givenPersistedCustomerInstance()).id;
|
|
175
|
+
await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 1' }, {
|
|
176
|
+
throughData: {
|
|
177
|
+
description: 'a through model',
|
|
178
|
+
promotiontype: 'HalfPrice',
|
|
179
|
+
},
|
|
180
|
+
polymorphicType: 'HalfPrice',
|
|
181
|
+
});
|
|
182
|
+
await (0, testlab_1.expect)(customerRepo
|
|
183
|
+
.promotions(existingCustomerId)
|
|
184
|
+
.patch({ HalfPrice: { id: anotherId } }, undefined, {
|
|
185
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
186
|
+
isPolymorphic: true,
|
|
187
|
+
})).to.be.rejectedWith(/Property "id" cannot be changed!/);
|
|
188
|
+
});
|
|
189
|
+
it('deletes many instances and their through models', async () => {
|
|
190
|
+
await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 1' }, {
|
|
191
|
+
throughData: {
|
|
192
|
+
description: 'a through model to be deleted',
|
|
193
|
+
promotiontype: 'HalfPrice',
|
|
194
|
+
},
|
|
195
|
+
polymorphicType: 'HalfPrice',
|
|
196
|
+
});
|
|
197
|
+
await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 1' }, {
|
|
198
|
+
throughData: {
|
|
199
|
+
description: 'a through model to be deleted 2',
|
|
200
|
+
promotiontype: 'HalfPrice',
|
|
201
|
+
},
|
|
202
|
+
polymorphicType: 'HalfPrice',
|
|
203
|
+
});
|
|
204
|
+
await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 1' }, {
|
|
205
|
+
throughData: {
|
|
206
|
+
description: 'a through model to be deleted 3',
|
|
207
|
+
promotiontype: 'FreeDelivery',
|
|
208
|
+
},
|
|
209
|
+
polymorphicType: 'FreeDelivery',
|
|
210
|
+
});
|
|
211
|
+
let links = await customerPromotionLinkRepo.find();
|
|
212
|
+
let halfPrice = await halfPriceRepo.find();
|
|
213
|
+
let freeDelivery = await freeDeliveryRepo.find();
|
|
214
|
+
(0, testlab_1.expect)(links).have.length(3);
|
|
215
|
+
(0, testlab_1.expect)(halfPrice).have.length(2);
|
|
216
|
+
(0, testlab_1.expect)(freeDelivery).have.length(1);
|
|
217
|
+
await customerRepo.promotions(existingCustomerId).delete(undefined, {
|
|
218
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
219
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
220
|
+
});
|
|
221
|
+
links = await customerPromotionLinkRepo.find();
|
|
222
|
+
halfPrice = await halfPriceRepo.find();
|
|
223
|
+
freeDelivery = await freeDeliveryRepo.find();
|
|
224
|
+
(0, testlab_1.expect)(halfPrice).have.length(0);
|
|
225
|
+
(0, testlab_1.expect)(freeDelivery).have.length(0);
|
|
226
|
+
(0, testlab_1.expect)(links).have.length(0);
|
|
227
|
+
});
|
|
228
|
+
it('deletes corresponding through models when the target gets deleted', async () => {
|
|
229
|
+
const promotion = await customerRepo
|
|
230
|
+
.promotions(existingCustomerId)
|
|
231
|
+
.create({ description: 'promo group 1' }, {
|
|
232
|
+
throughData: {
|
|
233
|
+
description: 'a through model to be deleted',
|
|
234
|
+
promotiontype: 'HalfPrice',
|
|
235
|
+
},
|
|
236
|
+
polymorphicType: 'HalfPrice',
|
|
237
|
+
});
|
|
238
|
+
const anotherId = (await givenPersistedCustomerInstance()).id;
|
|
239
|
+
// another through model that links to the same item
|
|
240
|
+
await customerPromotionLinkRepo.create({
|
|
241
|
+
customerId: anotherId,
|
|
242
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
243
|
+
promotion_id: promotion.id,
|
|
244
|
+
promotiontype: 'HalfPrice',
|
|
245
|
+
});
|
|
246
|
+
let links = await customerPromotionLinkRepo.find();
|
|
247
|
+
let halfPrice = await halfPriceRepo.find();
|
|
248
|
+
(0, testlab_1.expect)(links).have.length(2);
|
|
249
|
+
(0, testlab_1.expect)(halfPrice).have.length(1);
|
|
250
|
+
await customerRepo.promotions(existingCustomerId).delete(undefined, {
|
|
251
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
252
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
253
|
+
});
|
|
254
|
+
links = await customerPromotionLinkRepo.find();
|
|
255
|
+
halfPrice = await halfPriceRepo.find();
|
|
256
|
+
(0, testlab_1.expect)(links).have.length(0);
|
|
257
|
+
(0, testlab_1.expect)(halfPrice).have.length(0);
|
|
258
|
+
});
|
|
259
|
+
it('deletes instances based on the filter', async () => {
|
|
260
|
+
await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 1' }, {
|
|
261
|
+
throughData: {
|
|
262
|
+
description: 'a through model to be deleted',
|
|
263
|
+
promotiontype: 'HalfPrice',
|
|
264
|
+
},
|
|
265
|
+
polymorphicType: 'HalfPrice',
|
|
266
|
+
});
|
|
267
|
+
await customerRepo.promotions(existingCustomerId).create({ description: 'promo group 2' }, {
|
|
268
|
+
throughData: {
|
|
269
|
+
description: 'a through model to be deleted',
|
|
270
|
+
promotiontype: 'FreeDelivery',
|
|
271
|
+
},
|
|
272
|
+
polymorphicType: 'FreeDelivery',
|
|
273
|
+
});
|
|
274
|
+
let links = await customerPromotionLinkRepo.find();
|
|
275
|
+
let freeDelivery = await freeDeliveryRepo.find();
|
|
276
|
+
let halfPrice = await halfPriceRepo.find();
|
|
277
|
+
(0, testlab_1.expect)(links).have.length(2);
|
|
278
|
+
(0, testlab_1.expect)(freeDelivery).have.length(1);
|
|
279
|
+
(0, testlab_1.expect)(halfPrice).have.length(1);
|
|
280
|
+
await customerRepo.promotions(existingCustomerId).delete({ description: 'does not exist' }, {
|
|
281
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
282
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
283
|
+
});
|
|
284
|
+
links = await customerPromotionLinkRepo.find();
|
|
285
|
+
freeDelivery = await freeDeliveryRepo.find();
|
|
286
|
+
halfPrice = await halfPriceRepo.find();
|
|
287
|
+
(0, testlab_1.expect)(links).have.length(2);
|
|
288
|
+
(0, testlab_1.expect)(freeDelivery).have.length(1);
|
|
289
|
+
(0, testlab_1.expect)(halfPrice).have.length(1);
|
|
290
|
+
await customerRepo.promotions(existingCustomerId).delete({ description: 'promo group 2' }, {
|
|
291
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
292
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
293
|
+
});
|
|
294
|
+
links = await customerPromotionLinkRepo.find();
|
|
295
|
+
freeDelivery = await freeDeliveryRepo.find();
|
|
296
|
+
halfPrice = await halfPriceRepo.find();
|
|
297
|
+
(0, testlab_1.expect)(links).have.length(1);
|
|
298
|
+
(0, testlab_1.expect)(freeDelivery).have.length(0);
|
|
299
|
+
(0, testlab_1.expect)(halfPrice).have.length(1);
|
|
300
|
+
});
|
|
301
|
+
it('links a target model to a source model', async () => {
|
|
302
|
+
const freeDelivery = await freeDeliveryRepo.create({
|
|
303
|
+
description: 'a free delivery promotion',
|
|
304
|
+
});
|
|
305
|
+
let targets = await customerRepo
|
|
306
|
+
.promotions(existingCustomerId)
|
|
307
|
+
.find(undefined, {
|
|
308
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
309
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
310
|
+
});
|
|
311
|
+
(0, testlab_1.expect)(targets).to.be.empty();
|
|
312
|
+
await customerRepo
|
|
313
|
+
.promotions(existingCustomerId)
|
|
314
|
+
.link(freeDelivery.id, { throughData: { promotiontype: 'FreeDelivery' } });
|
|
315
|
+
targets = await customerRepo
|
|
316
|
+
.promotions(existingCustomerId)
|
|
317
|
+
.find(undefined, {
|
|
318
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
319
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
320
|
+
});
|
|
321
|
+
(0, testlab_1.expect)(targets).to.deepEqual([freeDelivery]);
|
|
322
|
+
const link = await customerPromotionLinkRepo.find();
|
|
323
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(link[0])).to.containEql(
|
|
324
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
325
|
+
(0, testlab_1.toJSON)({ customerId: existingCustomerId, promotion_id: freeDelivery.id }));
|
|
326
|
+
});
|
|
327
|
+
it('unlinks a target model from a source model', async () => {
|
|
328
|
+
const promotion1 = await customerRepo
|
|
329
|
+
.promotions(existingCustomerId)
|
|
330
|
+
.create({ description: 'promo group 1' }, {
|
|
331
|
+
throughData: {
|
|
332
|
+
description: 'a through model to be deleted',
|
|
333
|
+
promotiontype: 'HalfPrice',
|
|
334
|
+
},
|
|
335
|
+
polymorphicType: 'HalfPrice',
|
|
336
|
+
});
|
|
337
|
+
let targets = await customerRepo
|
|
338
|
+
.promotions(existingCustomerId)
|
|
339
|
+
.find(undefined, {
|
|
340
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
341
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
342
|
+
});
|
|
343
|
+
(0, testlab_1.expect)(targets).to.deepEqual([promotion1]);
|
|
344
|
+
await customerRepo.promotions(existingCustomerId).unlink(promotion1.id);
|
|
345
|
+
targets = await customerRepo
|
|
346
|
+
.promotions(existingCustomerId)
|
|
347
|
+
.find(undefined, {
|
|
348
|
+
throughOptions: { discriminator: 'promotiontype' },
|
|
349
|
+
polymorphicType: ['HalfPrice', 'FreeDelivery'],
|
|
350
|
+
});
|
|
351
|
+
(0, testlab_1.expect)(targets).to.be.empty();
|
|
352
|
+
const link = await customerPromotionLinkRepo.find();
|
|
353
|
+
(0, testlab_1.expect)(link).to.be.empty();
|
|
354
|
+
});
|
|
355
|
+
async function givenPersistedCustomerInstance() {
|
|
356
|
+
return customerRepo.create({ name: 'a customer' });
|
|
357
|
+
}
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
exports.hasManyThroughRelationAcceptance = hasManyThroughRelationAcceptance;
|
|
361
|
+
//# sourceMappingURL=has-many-through.relation.polymorphic.acceptance.js.map
|
package/dist/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-many-through.relation.polymorphic.acceptance.js","sourceRoot":"","sources":["../../../../src/crud/relations/acceptance/has-many-through.relation.polymorphic.acceptance.ts"],"names":[],"mappings":";AAAA,iDAAiD;AACjD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAEhE,+CAAiD;AAOjD,gFAI2C;AAC3C,+CAS4B;AAC5B,wCAAsD;AAEtD,SAAgB,gCAAgC,CAC9C,iBAAoC,EACpC,eAAmC,EACnC,QAAsB;IAEtB,QAAQ,CAAC,kDAAkD,EAAE,GAAG,EAAE;QAChE,MAAM,CAAC,6DAAkC,CAAC,CAAC;QAC3C,IAAI,YAAgC,CAAC;QACrC,IAAI,gBAAwC,CAAC;QAC7C,IAAI,aAAkC,CAAC;QACvC,IAAI,yBAA0D,CAAC;QAC/D,IAAI,kBAA+B,CAAC;QAEpC,MAAM,CACJ,IAAA,sCAAW,EAAC,KAAK,UAAU,eAAe,CAAC,GAAoB;YAC7D,CAAC;gBACC,YAAY;gBACZ,gBAAgB;gBAChB,aAAa;gBACb,yBAAyB;aAC1B,GAAG,IAAA,oCAA0B,EAC5B,GAAG,CAAC,UAAU,EACd,eAAe,EACf,QAAQ,CACT,CAAC,CAAC;YACH,MAAM,GAAG,CAAC,UAAU,CAAC,WAAW,CAAC;gBAC/B,iBAAQ,CAAC,IAAI;gBACb,qBAAY,CAAC,IAAI;gBACjB,kBAAS,CAAC,IAAI;gBACd,8BAAqB,CAAC,IAAI;aAC3B,CAAC,CAAC;QACL,CAAC,CAAC,CACH,CAAC;QAEF,UAAU,CAAC,KAAK,IAAI,EAAE;YACpB,MAAM,YAAY,CAAC,SAAS,EAAE,CAAC;YAC/B,MAAM,gBAAgB,CAAC,SAAS,EAAE,CAAC;YACnC,MAAM,aAAa,CAAC,SAAS,EAAE,CAAC;YAChC,MAAM,yBAAyB,CAAC,SAAS,EAAE,CAAC;QAC9C,CAAC,CAAC,CAAC;QAEH,UAAU,CAAC,KAAK,I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.
|
|
3
|
+
// Node module: @loopback/repository-tests
|
|
4
|
+
// This file is licensed under the MIT License.
|
|
5
|
+
// License text available at https://opensource.org/licenses/MIT
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.hasOneInclusionResolverPolymorphicAcceptance = void 0;
|
|
8
|
+
const testlab_1 = require("@loopback/testlab");
|
|
9
|
+
const helpers_repository_tests_1 = require("../../../helpers.repository-tests");
|
|
10
|
+
const models_1 = require("../fixtures/models");
|
|
11
|
+
const helpers_1 = require("../helpers");
|
|
12
|
+
function hasOneInclusionResolverPolymorphicAcceptance(dataSourceOptions, repositoryClass, features) {
|
|
13
|
+
(0, testlab_1.skipIf)(!features.supportsInclusionResolvers, describe, 'HasOne inclusion resolvers - polymorphic - acceptance', suite);
|
|
14
|
+
function suite() {
|
|
15
|
+
before(helpers_repository_tests_1.deleteAllModelsInDefaultDataSource);
|
|
16
|
+
let customerRepo;
|
|
17
|
+
let creditCardRepo;
|
|
18
|
+
let cashRepo;
|
|
19
|
+
let cardInfoRepo;
|
|
20
|
+
before((0, helpers_repository_tests_1.withCrudCtx)(async function setupRepository(ctx) {
|
|
21
|
+
// this helper should create the inclusion resolvers and also
|
|
22
|
+
// register inclusion resolvers for us
|
|
23
|
+
({ customerRepo, creditCardRepo, cashRepo, cardInfoRepo } =
|
|
24
|
+
(0, helpers_1.givenBoundCrudRepositories)(ctx.dataSource, repositoryClass, features));
|
|
25
|
+
(0, testlab_1.expect)(customerRepo.paymentMethod.inclusionResolver).to.be.Function();
|
|
26
|
+
await ctx.dataSource.automigrate([
|
|
27
|
+
models_1.Customer.name,
|
|
28
|
+
models_1.CreditCard.name,
|
|
29
|
+
models_1.Cash.name,
|
|
30
|
+
]);
|
|
31
|
+
}));
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
await customerRepo.deleteAll();
|
|
34
|
+
await creditCardRepo.deleteAll();
|
|
35
|
+
await cashRepo.deleteAll();
|
|
36
|
+
await cardInfoRepo.deleteAll();
|
|
37
|
+
});
|
|
38
|
+
it('throws an error if it tries to query nonexistent relation names', async () => {
|
|
39
|
+
const customer = await customerRepo.create({
|
|
40
|
+
name: 'customer',
|
|
41
|
+
paymentMethodType: 'CreditCard',
|
|
42
|
+
});
|
|
43
|
+
await creditCardRepo.create({
|
|
44
|
+
customerId: customer.id,
|
|
45
|
+
});
|
|
46
|
+
await (0, testlab_1.expect)(customerRepo.find({ include: ['home'] })).to.be.rejectedWith(`Invalid "filter.include" entries: "home"`);
|
|
47
|
+
});
|
|
48
|
+
it('returns single model instance including single related instance', async () => {
|
|
49
|
+
const thor = await customerRepo.create({
|
|
50
|
+
name: 'Thor',
|
|
51
|
+
paymentMethodType: 'CreditCard',
|
|
52
|
+
});
|
|
53
|
+
const thorCreditCard = await creditCardRepo.create({
|
|
54
|
+
customerId: thor.id,
|
|
55
|
+
});
|
|
56
|
+
const result = await customerRepo.find({
|
|
57
|
+
include: ['paymentMethod'],
|
|
58
|
+
});
|
|
59
|
+
const expected = {
|
|
60
|
+
...thor,
|
|
61
|
+
parentId: features.emptyValue,
|
|
62
|
+
paymentMethod: thorCreditCard,
|
|
63
|
+
};
|
|
64
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result)).to.deepEqual([(0, testlab_1.toJSON)(expected)]);
|
|
65
|
+
});
|
|
66
|
+
it('returns multiple model instances including related instances', async () => {
|
|
67
|
+
const thor = await customerRepo.create({
|
|
68
|
+
name: 'Thor',
|
|
69
|
+
paymentMethodType: 'Cash',
|
|
70
|
+
});
|
|
71
|
+
const odin = await customerRepo.create({
|
|
72
|
+
name: 'Odin',
|
|
73
|
+
paymentMethodType: 'CreditCard',
|
|
74
|
+
});
|
|
75
|
+
const thorCash = await cashRepo.create({
|
|
76
|
+
customerId: thor.id,
|
|
77
|
+
});
|
|
78
|
+
const odinCreditCard = await creditCardRepo.create({
|
|
79
|
+
customerId: odin.id,
|
|
80
|
+
});
|
|
81
|
+
const result = await customerRepo.find({
|
|
82
|
+
include: ['paymentMethod'],
|
|
83
|
+
});
|
|
84
|
+
const expected = [
|
|
85
|
+
{
|
|
86
|
+
...thor,
|
|
87
|
+
parentId: features.emptyValue,
|
|
88
|
+
paymentMethod: thorCash,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
...odin,
|
|
92
|
+
parentId: features.emptyValue,
|
|
93
|
+
paymentMethod: odinCreditCard,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result)).to.deepEqual((0, testlab_1.toJSON)(expected));
|
|
97
|
+
});
|
|
98
|
+
it('returns a specified instance including its related model instance', async () => {
|
|
99
|
+
const thor = await customerRepo.create({
|
|
100
|
+
name: 'Thor',
|
|
101
|
+
paymentMethodType: 'Cash',
|
|
102
|
+
});
|
|
103
|
+
const odin = await customerRepo.create({
|
|
104
|
+
name: 'Odin',
|
|
105
|
+
paymentMethodType: 'CreditCard',
|
|
106
|
+
});
|
|
107
|
+
const bella = await customerRepo.create({
|
|
108
|
+
name: 'Bella',
|
|
109
|
+
paymentMethodType: 'CreditCard',
|
|
110
|
+
});
|
|
111
|
+
await cashRepo.create({
|
|
112
|
+
customerId: thor.id,
|
|
113
|
+
});
|
|
114
|
+
await creditCardRepo.create({
|
|
115
|
+
customerId: odin.id,
|
|
116
|
+
});
|
|
117
|
+
const bellaPaymentMethod = await creditCardRepo.create({
|
|
118
|
+
customerId: bella.id,
|
|
119
|
+
});
|
|
120
|
+
const bellaCardInfo = await creditCardRepo
|
|
121
|
+
.cardInfo(bellaPaymentMethod.id)
|
|
122
|
+
.create({ cardHolder: 'bella!' });
|
|
123
|
+
bellaPaymentMethod.cardInfo = bellaCardInfo;
|
|
124
|
+
const result = await customerRepo.findById(bella.id, {
|
|
125
|
+
include: [
|
|
126
|
+
{
|
|
127
|
+
relation: 'paymentMethod',
|
|
128
|
+
scope: {
|
|
129
|
+
include: [
|
|
130
|
+
{
|
|
131
|
+
relation: 'cardInfo',
|
|
132
|
+
targetType: 'CreditCard',
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
});
|
|
139
|
+
const expected = {
|
|
140
|
+
...bella,
|
|
141
|
+
parentId: features.emptyValue,
|
|
142
|
+
paymentMethod: bellaPaymentMethod,
|
|
143
|
+
};
|
|
144
|
+
(0, testlab_1.expect)((0, testlab_1.toJSON)(result)).to.deepEqual((0, testlab_1.toJSON)(expected));
|
|
145
|
+
});
|
|
146
|
+
it('throws error if the target repository does not have the registered resolver', async () => {
|
|
147
|
+
const customer = await customerRepo.create({
|
|
148
|
+
name: 'customer',
|
|
149
|
+
paymentMethodType: 'CreditCard',
|
|
150
|
+
});
|
|
151
|
+
await creditCardRepo.create({
|
|
152
|
+
customerId: customer.id,
|
|
153
|
+
});
|
|
154
|
+
// unregister the resolver
|
|
155
|
+
customerRepo.inclusionResolvers.delete('paymentMethod');
|
|
156
|
+
await (0, testlab_1.expect)(customerRepo.find({ include: ['paymentMethod'] })).to.be.rejectedWith(`Invalid "filter.include" entries: "paymentMethod"`);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.hasOneInclusionResolverPolymorphicAcceptance = hasOneInclusionResolverPolymorphicAcceptance;
|
|
161
|
+
//# sourceMappingURL=has-one.inclusion-resolver.polymorphic.acceptance.js.map
|
package/dist/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"has-one.inclusion-resolver.polymorphic.acceptance.js","sourceRoot":"","sources":["../../../../src/crud/relations/acceptance/has-one.inclusion-resolver.polymorphic.acceptance.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,0CAA0C;AAC1C,+CAA+C;AAC/C,gEAAgE;;;AAEhE,+CAAyD;AAQzD,gFAG2C;AAC3C,+CAQ4B;AAC5B,wCAAsD;AAEtD,SAAgB,4CAA4C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