@feathersjs/adapter-tests 5.0.0-pre.1 → 5.0.0-pre.15
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/CHANGELOG.md +158 -4
- package/LICENSE +1 -1
- package/README.md +1 -1
- package/lib/index.js +3 -3
- package/lib/index.js.map +1 -1
- package/lib/methods.js +131 -140
- package/lib/methods.js.map +1 -1
- package/lib/syntax.js +125 -87
- package/lib/syntax.js.map +1 -1
- package/package.json +12 -10
- package/src/methods.ts +18 -18
- package/src/syntax.ts +54 -0
package/src/methods.ts
CHANGED
|
@@ -16,7 +16,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
16
16
|
afterEach(async () => {
|
|
17
17
|
try {
|
|
18
18
|
await app.service(serviceName).remove(doug[idProp]);
|
|
19
|
-
} catch (error) {}
|
|
19
|
+
} catch (error: any) {}
|
|
20
20
|
});
|
|
21
21
|
|
|
22
22
|
describe('get', () => {
|
|
@@ -48,7 +48,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
48
48
|
query: { name: 'Tester' }
|
|
49
49
|
});
|
|
50
50
|
throw new Error('Should never get here');
|
|
51
|
-
} catch (error) {
|
|
51
|
+
} catch (error: any) {
|
|
52
52
|
assert.strictEqual(error.name, 'NotFound',
|
|
53
53
|
'Got a NotFound Feathers error'
|
|
54
54
|
);
|
|
@@ -59,7 +59,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
59
59
|
try {
|
|
60
60
|
await service.get('568225fbfe21222432e836ff');
|
|
61
61
|
throw new Error('Should never get here');
|
|
62
|
-
} catch (error) {
|
|
62
|
+
} catch (error: any) {
|
|
63
63
|
assert.strictEqual(error.name, 'NotFound',
|
|
64
64
|
'Error is a NotFound Feathers error'
|
|
65
65
|
);
|
|
@@ -77,7 +77,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
77
77
|
query: { [idProp]: alice[idProp] }
|
|
78
78
|
});
|
|
79
79
|
throw new Error('Should never get here');
|
|
80
|
-
} catch (error) {
|
|
80
|
+
} catch (error: any) {
|
|
81
81
|
assert.strictEqual(error.name, 'NotFound',
|
|
82
82
|
'Got a NotFound Feathers error'
|
|
83
83
|
);
|
|
@@ -118,7 +118,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
118
118
|
query: { name: 'Tester' }
|
|
119
119
|
});
|
|
120
120
|
throw new Error('Should never get here');
|
|
121
|
-
} catch (error) {
|
|
121
|
+
} catch (error: any) {
|
|
122
122
|
assert.strictEqual(error.name, 'NotFound',
|
|
123
123
|
'Got a NotFound Feathers error'
|
|
124
124
|
);
|
|
@@ -129,7 +129,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
129
129
|
try {
|
|
130
130
|
await service.remove(null);
|
|
131
131
|
throw new Error('Should never get here');
|
|
132
|
-
} catch (error) {
|
|
132
|
+
} catch (error: any) {
|
|
133
133
|
assert.strictEqual(error.name, 'MethodNotAllowed',
|
|
134
134
|
'Removing multiple without option set throws MethodNotAllowed'
|
|
135
135
|
);
|
|
@@ -167,7 +167,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
167
167
|
query: { [idProp]: alice[idProp] }
|
|
168
168
|
});
|
|
169
169
|
throw new Error('Should never get here');
|
|
170
|
-
} catch (error) {
|
|
170
|
+
} catch (error: any) {
|
|
171
171
|
assert.strictEqual(error.name, 'NotFound',
|
|
172
172
|
'Got a NotFound Feathers error'
|
|
173
173
|
);
|
|
@@ -217,7 +217,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
217
217
|
query: { name: 'Tester' }
|
|
218
218
|
});
|
|
219
219
|
throw new Error('Should never get here');
|
|
220
|
-
} catch (error) {
|
|
220
|
+
} catch (error: any) {
|
|
221
221
|
assert.strictEqual(error.name, 'NotFound',
|
|
222
222
|
'Got a NotFound Feathers error'
|
|
223
223
|
);
|
|
@@ -228,7 +228,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
228
228
|
try {
|
|
229
229
|
await service.update('568225fbfe21222432e836ff', { name: 'NotFound' });
|
|
230
230
|
throw new Error('Should never get here');
|
|
231
|
-
} catch (error) {
|
|
231
|
+
} catch (error: any) {
|
|
232
232
|
assert.strictEqual(error.name, 'NotFound',
|
|
233
233
|
'Error is a NotFound Feathers error'
|
|
234
234
|
);
|
|
@@ -244,7 +244,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
244
244
|
{ query: { name: 'NotDave' } }
|
|
245
245
|
);
|
|
246
246
|
throw new Error('Should never get here');
|
|
247
|
-
} catch (error) {
|
|
247
|
+
} catch (error: any) {
|
|
248
248
|
assert.strictEqual(error.name, 'NotFound',
|
|
249
249
|
'Error is a NotFound Feathers error'
|
|
250
250
|
);
|
|
@@ -266,7 +266,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
266
266
|
query: { [idProp]: alice[idProp] }
|
|
267
267
|
});
|
|
268
268
|
throw new Error('Should never get here');
|
|
269
|
-
} catch (error) {
|
|
269
|
+
} catch (error: any) {
|
|
270
270
|
assert.strictEqual(error.name, 'NotFound',
|
|
271
271
|
'Got a NotFound Feathers error'
|
|
272
272
|
);
|
|
@@ -312,7 +312,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
312
312
|
query: { name: 'Tester' }
|
|
313
313
|
});
|
|
314
314
|
throw new Error('Should never get here');
|
|
315
|
-
} catch (error) {
|
|
315
|
+
} catch (error: any) {
|
|
316
316
|
assert.strictEqual(error.name, 'NotFound',
|
|
317
317
|
'Got a NotFound Feathers error'
|
|
318
318
|
);
|
|
@@ -323,7 +323,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
323
323
|
try {
|
|
324
324
|
await service.patch(null, {});
|
|
325
325
|
throw new Error('Should never get here');
|
|
326
|
-
} catch (error) {
|
|
326
|
+
} catch (error: any) {
|
|
327
327
|
assert.strictEqual(error.name, 'MethodNotAllowed',
|
|
328
328
|
'Removing multiple without option set throws MethodNotAllowed'
|
|
329
329
|
);
|
|
@@ -417,7 +417,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
417
417
|
try {
|
|
418
418
|
await service.patch('568225fbfe21222432e836ff', { name: 'PatchDoug' });
|
|
419
419
|
throw new Error('Should never get here');
|
|
420
|
-
} catch (error) {
|
|
420
|
+
} catch (error: any) {
|
|
421
421
|
assert.strictEqual(error.name, 'NotFound',
|
|
422
422
|
'Error is a NotFound Feathers error'
|
|
423
423
|
);
|
|
@@ -433,7 +433,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
433
433
|
{ query: { name: 'NotDave' } }
|
|
434
434
|
);
|
|
435
435
|
throw new Error('Should never get here');
|
|
436
|
-
} catch (error) {
|
|
436
|
+
} catch (error: any) {
|
|
437
437
|
assert.strictEqual(error.name, 'NotFound',
|
|
438
438
|
'Error is a NotFound Feathers error'
|
|
439
439
|
);
|
|
@@ -454,7 +454,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
454
454
|
query: { [idProp]: alice[idProp] }
|
|
455
455
|
});
|
|
456
456
|
throw new Error('Should never get here');
|
|
457
|
-
} catch (error) {
|
|
457
|
+
} catch (error: any) {
|
|
458
458
|
assert.strictEqual(error.name, 'NotFound',
|
|
459
459
|
'Got a NotFound Feathers error'
|
|
460
460
|
);
|
|
@@ -503,7 +503,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
503
503
|
try {
|
|
504
504
|
await service.create([], {});
|
|
505
505
|
throw new Error('Should never get here');
|
|
506
|
-
} catch (error) {
|
|
506
|
+
} catch (error: any) {
|
|
507
507
|
assert.strictEqual(error.name, 'MethodNotAllowed',
|
|
508
508
|
'Removing multiple without option set throws MethodNotAllowed'
|
|
509
509
|
);
|
|
@@ -539,7 +539,7 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
539
539
|
let throwing: any;
|
|
540
540
|
|
|
541
541
|
before(() => {
|
|
542
|
-
throwing = app.service(serviceName)
|
|
542
|
+
throwing = Object.assign(Object.create(app.service(serviceName)), {
|
|
543
543
|
get store () {
|
|
544
544
|
return app.service(serviceName).store;
|
|
545
545
|
},
|
package/src/syntax.ts
CHANGED
|
@@ -276,6 +276,46 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
276
276
|
assert.strictEqual(data[1].name, 'Doug');
|
|
277
277
|
});
|
|
278
278
|
|
|
279
|
+
describe('params.adapter', () => {
|
|
280
|
+
test('params.adapter + paginate', async () => {
|
|
281
|
+
const page = await service.find({
|
|
282
|
+
adapter: {
|
|
283
|
+
paginate: { default: 3 }
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
assert.strictEqual(page.limit, 3);
|
|
288
|
+
assert.strictEqual(page.skip, 0);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
test('params.adapter + multi', async () => {
|
|
292
|
+
const items = [
|
|
293
|
+
{
|
|
294
|
+
name: 'Garald',
|
|
295
|
+
age: 200
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
name: 'Harald',
|
|
299
|
+
age: 24
|
|
300
|
+
}
|
|
301
|
+
];
|
|
302
|
+
const multiParams = {
|
|
303
|
+
adapter: {
|
|
304
|
+
multi: ['create']
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
const users = await service.create(items, multiParams);
|
|
308
|
+
|
|
309
|
+
assert.strictEqual(users.length, 2);
|
|
310
|
+
|
|
311
|
+
await service.remove(users[0][idProp]);
|
|
312
|
+
await service.remove(users[1][idProp]);
|
|
313
|
+
await assert.rejects(() => service.patch(null, { age: 2 }, multiParams), {
|
|
314
|
+
message: 'Can not patch multiple entries'
|
|
315
|
+
});
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
|
|
279
319
|
describe('paginate', function () {
|
|
280
320
|
beforeEach(() => {
|
|
281
321
|
service.options.paginate = {
|
|
@@ -299,6 +339,20 @@ export default (test: any, app: any, _errors: any, serviceName: string, idProp:
|
|
|
299
339
|
assert.strictEqual(page.data[0].name, 'Doug');
|
|
300
340
|
});
|
|
301
341
|
|
|
342
|
+
test('.find + paginate + query', async () => {
|
|
343
|
+
const page = await service.find({
|
|
344
|
+
query: {
|
|
345
|
+
$sort: { name: -1 },
|
|
346
|
+
name: 'Doug'
|
|
347
|
+
}
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
assert.strictEqual(page.total, 1);
|
|
351
|
+
assert.strictEqual(page.limit, 1);
|
|
352
|
+
assert.strictEqual(page.skip, 0);
|
|
353
|
+
assert.strictEqual(page.data[0].name, 'Doug');
|
|
354
|
+
});
|
|
355
|
+
|
|
302
356
|
test('.find + paginate + $limit + $skip', async () => {
|
|
303
357
|
const params = {
|
|
304
358
|
query: {
|