@feathersjs/adapter-tests 5.0.0-pre.22 → 5.0.0-pre.25
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 +24 -0
- package/lib/basic.js.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/methods.js +29 -12
- package/lib/methods.js.map +1 -1
- package/lib/syntax.js +1 -4
- package/lib/syntax.js.map +1 -1
- package/package.json +5 -5
- package/src/basic.ts +38 -42
- package/src/declarations.ts +82 -82
- package/src/index.ts +29 -27
- package/src/methods.ts +370 -375
- package/src/syntax.ts +152 -155
package/src/methods.ts
CHANGED
|
@@ -1,621 +1,622 @@
|
|
|
1
|
-
import assert from 'assert'
|
|
2
|
-
import { AdapterMethodsTest } from './declarations'
|
|
1
|
+
import assert from 'assert'
|
|
2
|
+
import { AdapterMethodsTest } from './declarations'
|
|
3
3
|
|
|
4
4
|
export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: string, idProp: string) => {
|
|
5
5
|
describe(' Methods', () => {
|
|
6
|
-
let doug: any
|
|
7
|
-
let service: any
|
|
6
|
+
let doug: any
|
|
7
|
+
let service: any
|
|
8
8
|
|
|
9
9
|
beforeEach(async () => {
|
|
10
|
-
service = app.service(serviceName)
|
|
10
|
+
service = app.service(serviceName)
|
|
11
11
|
doug = await app.service(serviceName).create({
|
|
12
12
|
name: 'Doug',
|
|
13
13
|
age: 32
|
|
14
|
-
})
|
|
15
|
-
})
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
16
|
|
|
17
17
|
afterEach(async () => {
|
|
18
18
|
try {
|
|
19
|
-
await app.service(serviceName).remove(doug[idProp])
|
|
19
|
+
await app.service(serviceName).remove(doug[idProp])
|
|
20
20
|
} catch (error: any) {}
|
|
21
|
-
})
|
|
21
|
+
})
|
|
22
22
|
|
|
23
23
|
describe('get', () => {
|
|
24
24
|
test('.get', async () => {
|
|
25
|
-
const data = await service.get(doug[idProp])
|
|
25
|
+
const data = await service.get(doug[idProp])
|
|
26
26
|
|
|
27
|
-
assert.strictEqual(data[idProp].toString(), doug[idProp].toString(),
|
|
28
|
-
|
|
29
|
-
)
|
|
30
|
-
|
|
31
|
-
assert.strictEqual(data.age, 32, 'data.age matches');
|
|
32
|
-
});
|
|
27
|
+
assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id matches`)
|
|
28
|
+
assert.strictEqual(data.name, 'Doug', 'data.name matches')
|
|
29
|
+
assert.strictEqual(data.age, 32, 'data.age matches')
|
|
30
|
+
})
|
|
33
31
|
|
|
34
32
|
test('.get + $select', async () => {
|
|
35
33
|
const data = await service.get(doug[idProp], {
|
|
36
|
-
query: { $select: [
|
|
37
|
-
})
|
|
34
|
+
query: { $select: ['name'] }
|
|
35
|
+
})
|
|
38
36
|
|
|
39
|
-
assert.strictEqual(data[idProp].toString(), doug[idProp].toString(),
|
|
40
|
-
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
assert.ok(!data.age, 'data.age is falsy');
|
|
44
|
-
});
|
|
37
|
+
assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id property matches`)
|
|
38
|
+
assert.strictEqual(data.name, 'Doug', 'data.name matches')
|
|
39
|
+
assert.ok(!data.age, 'data.age is falsy')
|
|
40
|
+
})
|
|
45
41
|
|
|
46
42
|
test('.get + id + query', async () => {
|
|
47
43
|
try {
|
|
48
44
|
await service.get(doug[idProp], {
|
|
49
45
|
query: { name: 'Tester' }
|
|
50
|
-
})
|
|
51
|
-
throw new Error('Should never get here')
|
|
46
|
+
})
|
|
47
|
+
throw new Error('Should never get here')
|
|
52
48
|
} catch (error: any) {
|
|
53
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
54
|
-
'Got a NotFound Feathers error'
|
|
55
|
-
);
|
|
49
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
56
50
|
}
|
|
57
|
-
})
|
|
51
|
+
})
|
|
58
52
|
|
|
59
53
|
test('.get + NotFound', async () => {
|
|
60
54
|
try {
|
|
61
|
-
await service.get('568225fbfe21222432e836ff')
|
|
62
|
-
throw new Error('Should never get here')
|
|
55
|
+
await service.get('568225fbfe21222432e836ff')
|
|
56
|
+
throw new Error('Should never get here')
|
|
63
57
|
} catch (error: any) {
|
|
64
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
65
|
-
'Error is a NotFound Feathers error'
|
|
66
|
-
);
|
|
58
|
+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
|
|
67
59
|
}
|
|
68
|
-
})
|
|
60
|
+
})
|
|
69
61
|
|
|
70
62
|
test('.get + id + query id', async () => {
|
|
71
63
|
const alice = await service.create({
|
|
72
64
|
name: 'Alice',
|
|
73
65
|
age: 12
|
|
74
|
-
})
|
|
66
|
+
})
|
|
75
67
|
|
|
76
68
|
try {
|
|
77
69
|
await service.get(doug[idProp], {
|
|
78
70
|
query: { [idProp]: alice[idProp] }
|
|
79
|
-
})
|
|
80
|
-
throw new Error('Should never get here')
|
|
71
|
+
})
|
|
72
|
+
throw new Error('Should never get here')
|
|
81
73
|
} catch (error: any) {
|
|
82
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
83
|
-
'Got a NotFound Feathers error'
|
|
84
|
-
);
|
|
74
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
85
75
|
}
|
|
86
76
|
|
|
87
|
-
await service.remove(alice[idProp])
|
|
88
|
-
})
|
|
89
|
-
})
|
|
77
|
+
await service.remove(alice[idProp])
|
|
78
|
+
})
|
|
79
|
+
})
|
|
90
80
|
|
|
91
81
|
describe('find', () => {
|
|
92
82
|
test('.find', async () => {
|
|
93
|
-
const data = await service.find()
|
|
83
|
+
const data = await service.find()
|
|
94
84
|
|
|
95
|
-
assert.ok(Array.isArray(data), 'Data is an array')
|
|
96
|
-
assert.strictEqual(data.length, 1, 'Got one entry')
|
|
97
|
-
})
|
|
98
|
-
})
|
|
85
|
+
assert.ok(Array.isArray(data), 'Data is an array')
|
|
86
|
+
assert.strictEqual(data.length, 1, 'Got one entry')
|
|
87
|
+
})
|
|
88
|
+
})
|
|
99
89
|
|
|
100
90
|
describe('remove', () => {
|
|
101
91
|
test('.remove', async () => {
|
|
102
|
-
const data = await service.remove(doug[idProp])
|
|
92
|
+
const data = await service.remove(doug[idProp])
|
|
103
93
|
|
|
104
|
-
assert.strictEqual(data.name, 'Doug', 'data.name matches')
|
|
105
|
-
})
|
|
94
|
+
assert.strictEqual(data.name, 'Doug', 'data.name matches')
|
|
95
|
+
})
|
|
106
96
|
|
|
107
97
|
test('.remove + $select', async () => {
|
|
108
98
|
const data = await service.remove(doug[idProp], {
|
|
109
|
-
query: { $select: [
|
|
110
|
-
})
|
|
99
|
+
query: { $select: ['name'] }
|
|
100
|
+
})
|
|
111
101
|
|
|
112
|
-
assert.strictEqual(data.name, 'Doug', 'data.name matches')
|
|
113
|
-
assert.ok(!data.age, 'data.age is falsy')
|
|
114
|
-
})
|
|
102
|
+
assert.strictEqual(data.name, 'Doug', 'data.name matches')
|
|
103
|
+
assert.ok(!data.age, 'data.age is falsy')
|
|
104
|
+
})
|
|
115
105
|
|
|
116
106
|
test('.remove + id + query', async () => {
|
|
117
107
|
try {
|
|
118
108
|
await service.remove(doug[idProp], {
|
|
119
109
|
query: { name: 'Tester' }
|
|
120
|
-
})
|
|
121
|
-
throw new Error('Should never get here')
|
|
110
|
+
})
|
|
111
|
+
throw new Error('Should never get here')
|
|
122
112
|
} catch (error: any) {
|
|
123
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
124
|
-
'Got a NotFound Feathers error'
|
|
125
|
-
);
|
|
113
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
126
114
|
}
|
|
127
|
-
})
|
|
115
|
+
})
|
|
128
116
|
|
|
129
117
|
test('.remove + multi', async () => {
|
|
130
118
|
try {
|
|
131
|
-
await service.remove(null)
|
|
132
|
-
throw new Error('Should never get here')
|
|
119
|
+
await service.remove(null)
|
|
120
|
+
throw new Error('Should never get here')
|
|
133
121
|
} catch (error: any) {
|
|
134
|
-
assert.strictEqual(
|
|
122
|
+
assert.strictEqual(
|
|
123
|
+
error.name,
|
|
124
|
+
'MethodNotAllowed',
|
|
135
125
|
'Removing multiple without option set throws MethodNotAllowed'
|
|
136
|
-
)
|
|
126
|
+
)
|
|
137
127
|
}
|
|
138
128
|
|
|
139
|
-
service.options.multi = [
|
|
129
|
+
service.options.multi = ['remove']
|
|
140
130
|
|
|
141
|
-
await service.create({ name: 'Dave', age: 29, created: true })
|
|
131
|
+
await service.create({ name: 'Dave', age: 29, created: true })
|
|
142
132
|
await service.create({
|
|
143
133
|
name: 'David',
|
|
144
134
|
age: 3,
|
|
145
135
|
created: true
|
|
146
|
-
})
|
|
136
|
+
})
|
|
147
137
|
|
|
148
138
|
const data = await service.remove(null, {
|
|
149
139
|
query: { created: true }
|
|
150
|
-
})
|
|
140
|
+
})
|
|
151
141
|
|
|
152
|
-
assert.strictEqual(data.length, 2)
|
|
142
|
+
assert.strictEqual(data.length, 2)
|
|
153
143
|
|
|
154
|
-
const names = data.map((person: any) => person.name)
|
|
144
|
+
const names = data.map((person: any) => person.name)
|
|
155
145
|
|
|
156
|
-
assert.ok(names.includes('Dave'), 'Dave removed')
|
|
157
|
-
assert.ok(names.includes('David'), 'David removed')
|
|
158
|
-
})
|
|
146
|
+
assert.ok(names.includes('Dave'), 'Dave removed')
|
|
147
|
+
assert.ok(names.includes('David'), 'David removed')
|
|
148
|
+
})
|
|
159
149
|
|
|
160
150
|
test('.remove + multi no pagination', async () => {
|
|
161
151
|
try {
|
|
162
|
-
await service.remove(doug[idProp])
|
|
152
|
+
await service.remove(doug[idProp])
|
|
163
153
|
} catch (error: any) {}
|
|
164
154
|
|
|
165
|
-
const count = 14
|
|
166
|
-
const defaultPaginate = 10
|
|
155
|
+
const count = 14
|
|
156
|
+
const defaultPaginate = 10
|
|
167
157
|
|
|
168
|
-
assert.ok(count > defaultPaginate, 'count is bigger than default pagination')
|
|
158
|
+
assert.ok(count > defaultPaginate, 'count is bigger than default pagination')
|
|
169
159
|
|
|
170
|
-
const multiBefore = service.options.multi
|
|
171
|
-
const paginateBefore = service.options.paginate
|
|
160
|
+
const multiBefore = service.options.multi
|
|
161
|
+
const paginateBefore = service.options.paginate
|
|
172
162
|
|
|
173
163
|
try {
|
|
174
|
-
service.options.multi = true
|
|
164
|
+
service.options.multi = true
|
|
175
165
|
service.options.paginate = {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
}
|
|
166
|
+
default: defaultPaginate,
|
|
167
|
+
max: 100
|
|
168
|
+
}
|
|
179
169
|
|
|
180
|
-
const emptyItems = await service.find({ paginate: false })
|
|
170
|
+
const emptyItems = await service.find({ paginate: false })
|
|
181
171
|
assert.strictEqual(emptyItems.length, 0, 'no items before')
|
|
182
172
|
|
|
183
173
|
const createdItems = await service.create(
|
|
184
|
-
Array.from(Array(count)).map((_, i) => ({
|
|
185
|
-
|
|
186
|
-
|
|
174
|
+
Array.from(Array(count)).map((_, i) => ({
|
|
175
|
+
name: `name-${i}`,
|
|
176
|
+
age: 3,
|
|
177
|
+
created: true
|
|
178
|
+
}))
|
|
179
|
+
)
|
|
180
|
+
assert.strictEqual(createdItems.length, count, `created ${count} items`)
|
|
187
181
|
|
|
188
|
-
const foundItems = await service.find({ paginate: false })
|
|
189
|
-
assert.strictEqual(foundItems.length, count, `created ${count} items`)
|
|
182
|
+
const foundItems = await service.find({ paginate: false })
|
|
183
|
+
assert.strictEqual(foundItems.length, count, `created ${count} items`)
|
|
190
184
|
|
|
191
|
-
const foundPaginatedItems = await service.find({})
|
|
192
|
-
assert.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated items')
|
|
185
|
+
const foundPaginatedItems = await service.find({})
|
|
186
|
+
assert.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated items')
|
|
193
187
|
|
|
194
|
-
const allItems = await service.remove(null, {
|
|
188
|
+
const allItems = await service.remove(null, {
|
|
189
|
+
query: { created: true }
|
|
190
|
+
})
|
|
195
191
|
|
|
196
|
-
assert.strictEqual(allItems.length, count, `removed all ${
|
|
192
|
+
assert.strictEqual(allItems.length, count, `removed all ${count} items`)
|
|
197
193
|
} finally {
|
|
198
|
-
await service.remove(null, {
|
|
194
|
+
await service.remove(null, {
|
|
195
|
+
query: { created: true },
|
|
196
|
+
paginate: false
|
|
197
|
+
})
|
|
199
198
|
|
|
200
|
-
service.options.multi = multiBefore
|
|
201
|
-
service.options.paginate = paginateBefore
|
|
199
|
+
service.options.multi = multiBefore
|
|
200
|
+
service.options.paginate = paginateBefore
|
|
202
201
|
}
|
|
203
|
-
})
|
|
202
|
+
})
|
|
204
203
|
|
|
205
204
|
test('.remove + id + query id', async () => {
|
|
206
205
|
const alice = await service.create({
|
|
207
206
|
name: 'Alice',
|
|
208
207
|
age: 12
|
|
209
|
-
})
|
|
208
|
+
})
|
|
210
209
|
|
|
211
210
|
try {
|
|
212
211
|
await service.remove(doug[idProp], {
|
|
213
212
|
query: { [idProp]: alice[idProp] }
|
|
214
|
-
})
|
|
215
|
-
throw new Error('Should never get here')
|
|
213
|
+
})
|
|
214
|
+
throw new Error('Should never get here')
|
|
216
215
|
} catch (error: any) {
|
|
217
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
218
|
-
'Got a NotFound Feathers error'
|
|
219
|
-
);
|
|
216
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
220
217
|
}
|
|
221
218
|
|
|
222
|
-
await service.remove(alice[idProp])
|
|
223
|
-
})
|
|
224
|
-
})
|
|
219
|
+
await service.remove(alice[idProp])
|
|
220
|
+
})
|
|
221
|
+
})
|
|
225
222
|
|
|
226
223
|
describe('update', () => {
|
|
227
224
|
test('.update', async () => {
|
|
228
|
-
const originalData = { [idProp]: doug[idProp], name: 'Dougler' }
|
|
229
|
-
const originalCopy = Object.assign({}, originalData)
|
|
225
|
+
const originalData = { [idProp]: doug[idProp], name: 'Dougler' }
|
|
226
|
+
const originalCopy = Object.assign({}, originalData)
|
|
230
227
|
|
|
231
|
-
const data = await service.update(doug[idProp], originalData)
|
|
228
|
+
const data = await service.update(doug[idProp], originalData)
|
|
232
229
|
|
|
233
|
-
assert.deepStrictEqual(originalData, originalCopy,
|
|
234
|
-
|
|
235
|
-
)
|
|
236
|
-
assert.
|
|
237
|
-
|
|
238
|
-
);
|
|
239
|
-
assert.strictEqual(data.name, 'Dougler', 'data.name matches');
|
|
240
|
-
assert.ok(!data.age, 'data.age is falsy');
|
|
241
|
-
});
|
|
230
|
+
assert.deepStrictEqual(originalData, originalCopy, 'data was not modified')
|
|
231
|
+
assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id matches`)
|
|
232
|
+
assert.strictEqual(data.name, 'Dougler', 'data.name matches')
|
|
233
|
+
assert.ok(!data.age, 'data.age is falsy')
|
|
234
|
+
})
|
|
242
235
|
|
|
243
236
|
test('.update + $select', async () => {
|
|
244
237
|
const originalData = {
|
|
245
238
|
[idProp]: doug[idProp],
|
|
246
239
|
name: 'Dougler',
|
|
247
240
|
age: 10
|
|
248
|
-
}
|
|
241
|
+
}
|
|
249
242
|
|
|
250
243
|
const data = await service.update(doug[idProp], originalData, {
|
|
251
|
-
query: { $select: [
|
|
252
|
-
})
|
|
244
|
+
query: { $select: ['name'] }
|
|
245
|
+
})
|
|
253
246
|
|
|
254
|
-
assert.strictEqual(data.name, 'Dougler', 'data.name matches')
|
|
255
|
-
assert.ok(!data.age, 'data.age is falsy')
|
|
256
|
-
})
|
|
247
|
+
assert.strictEqual(data.name, 'Dougler', 'data.name matches')
|
|
248
|
+
assert.ok(!data.age, 'data.age is falsy')
|
|
249
|
+
})
|
|
257
250
|
|
|
258
251
|
test('.update + id + query', async () => {
|
|
259
252
|
try {
|
|
260
|
-
await service.update(
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
253
|
+
await service.update(
|
|
254
|
+
doug[idProp],
|
|
255
|
+
{
|
|
256
|
+
name: 'Dougler'
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
query: { name: 'Tester' }
|
|
260
|
+
}
|
|
261
|
+
)
|
|
262
|
+
throw new Error('Should never get here')
|
|
266
263
|
} catch (error: any) {
|
|
267
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
268
|
-
'Got a NotFound Feathers error'
|
|
269
|
-
);
|
|
264
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
270
265
|
}
|
|
271
|
-
})
|
|
266
|
+
})
|
|
272
267
|
|
|
273
268
|
test('.update + NotFound', async () => {
|
|
274
269
|
try {
|
|
275
|
-
await service.update('568225fbfe21222432e836ff', {
|
|
276
|
-
|
|
270
|
+
await service.update('568225fbfe21222432e836ff', {
|
|
271
|
+
name: 'NotFound'
|
|
272
|
+
})
|
|
273
|
+
throw new Error('Should never get here')
|
|
277
274
|
} catch (error: any) {
|
|
278
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
279
|
-
'Error is a NotFound Feathers error'
|
|
280
|
-
);
|
|
275
|
+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
|
|
281
276
|
}
|
|
282
|
-
})
|
|
277
|
+
})
|
|
283
278
|
|
|
284
279
|
test('.update + query + NotFound', async () => {
|
|
285
|
-
const dave = await service.create({ name: 'Dave' })
|
|
280
|
+
const dave = await service.create({ name: 'Dave' })
|
|
286
281
|
try {
|
|
287
|
-
await service.update(
|
|
288
|
-
|
|
289
|
-
{ name: 'UpdatedDave' },
|
|
290
|
-
{ query: { name: 'NotDave' } }
|
|
291
|
-
);
|
|
292
|
-
throw new Error('Should never get here');
|
|
282
|
+
await service.update(dave[idProp], { name: 'UpdatedDave' }, { query: { name: 'NotDave' } })
|
|
283
|
+
throw new Error('Should never get here')
|
|
293
284
|
} catch (error: any) {
|
|
294
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
295
|
-
'Error is a NotFound Feathers error'
|
|
296
|
-
);
|
|
285
|
+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
|
|
297
286
|
}
|
|
298
|
-
await service.remove(dave[idProp])
|
|
299
|
-
})
|
|
287
|
+
await service.remove(dave[idProp])
|
|
288
|
+
})
|
|
300
289
|
|
|
301
290
|
test('.update + id + query id', async () => {
|
|
302
291
|
const alice = await service.create({
|
|
303
292
|
name: 'Alice',
|
|
304
293
|
age: 12
|
|
305
|
-
})
|
|
294
|
+
})
|
|
306
295
|
|
|
307
296
|
try {
|
|
308
|
-
await service.update(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
297
|
+
await service.update(
|
|
298
|
+
doug[idProp],
|
|
299
|
+
{
|
|
300
|
+
name: 'Dougler',
|
|
301
|
+
age: 33
|
|
302
|
+
},
|
|
303
|
+
{
|
|
304
|
+
query: { [idProp]: alice[idProp] }
|
|
305
|
+
}
|
|
306
|
+
)
|
|
307
|
+
throw new Error('Should never get here')
|
|
315
308
|
} catch (error: any) {
|
|
316
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
317
|
-
'Got a NotFound Feathers error'
|
|
318
|
-
);
|
|
309
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
319
310
|
}
|
|
320
311
|
|
|
321
|
-
await service.remove(alice[idProp])
|
|
322
|
-
})
|
|
323
|
-
})
|
|
312
|
+
await service.remove(alice[idProp])
|
|
313
|
+
})
|
|
314
|
+
})
|
|
324
315
|
|
|
325
316
|
describe('patch', () => {
|
|
326
317
|
test('.patch', async () => {
|
|
327
|
-
const originalData = { [idProp]: doug[idProp], name: 'PatchDoug' }
|
|
328
|
-
const originalCopy = Object.assign({}, originalData)
|
|
318
|
+
const originalData = { [idProp]: doug[idProp], name: 'PatchDoug' }
|
|
319
|
+
const originalCopy = Object.assign({}, originalData)
|
|
329
320
|
|
|
330
|
-
const data = await service.patch(doug[idProp], originalData)
|
|
321
|
+
const data = await service.patch(doug[idProp], originalData)
|
|
331
322
|
|
|
332
|
-
assert.deepStrictEqual(originalData, originalCopy,
|
|
333
|
-
|
|
334
|
-
)
|
|
335
|
-
assert.strictEqual(data
|
|
336
|
-
|
|
337
|
-
);
|
|
338
|
-
assert.strictEqual(data.name, 'PatchDoug', 'data.name matches');
|
|
339
|
-
assert.strictEqual(data.age, 32, 'data.age matches');
|
|
340
|
-
});
|
|
323
|
+
assert.deepStrictEqual(originalData, originalCopy, 'original data was not modified')
|
|
324
|
+
assert.strictEqual(data[idProp].toString(), doug[idProp].toString(), `${idProp} id matches`)
|
|
325
|
+
assert.strictEqual(data.name, 'PatchDoug', 'data.name matches')
|
|
326
|
+
assert.strictEqual(data.age, 32, 'data.age matches')
|
|
327
|
+
})
|
|
341
328
|
|
|
342
329
|
test('.patch + $select', async () => {
|
|
343
|
-
const originalData = { [idProp]: doug[idProp], name: 'PatchDoug' }
|
|
330
|
+
const originalData = { [idProp]: doug[idProp], name: 'PatchDoug' }
|
|
344
331
|
|
|
345
332
|
const data = await service.patch(doug[idProp], originalData, {
|
|
346
|
-
query: { $select: [
|
|
347
|
-
})
|
|
333
|
+
query: { $select: ['name'] }
|
|
334
|
+
})
|
|
348
335
|
|
|
349
|
-
assert.strictEqual(data.name, 'PatchDoug', 'data.name matches')
|
|
350
|
-
assert.ok(!data.age, 'data.age is falsy')
|
|
351
|
-
})
|
|
336
|
+
assert.strictEqual(data.name, 'PatchDoug', 'data.name matches')
|
|
337
|
+
assert.ok(!data.age, 'data.age is falsy')
|
|
338
|
+
})
|
|
352
339
|
|
|
353
340
|
test('.patch + id + query', async () => {
|
|
354
341
|
try {
|
|
355
|
-
await service.patch(
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
342
|
+
await service.patch(
|
|
343
|
+
doug[idProp],
|
|
344
|
+
{
|
|
345
|
+
name: 'id patched doug'
|
|
346
|
+
},
|
|
347
|
+
{
|
|
348
|
+
query: { name: 'Tester' }
|
|
349
|
+
}
|
|
350
|
+
)
|
|
351
|
+
throw new Error('Should never get here')
|
|
361
352
|
} catch (error: any) {
|
|
362
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
363
|
-
'Got a NotFound Feathers error'
|
|
364
|
-
);
|
|
353
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
365
354
|
}
|
|
366
|
-
})
|
|
355
|
+
})
|
|
367
356
|
|
|
368
357
|
test('.patch multiple', async () => {
|
|
369
358
|
try {
|
|
370
|
-
await service.patch(null, {})
|
|
371
|
-
throw new Error('Should never get here')
|
|
359
|
+
await service.patch(null, {})
|
|
360
|
+
throw new Error('Should never get here')
|
|
372
361
|
} catch (error: any) {
|
|
373
|
-
assert.strictEqual(
|
|
362
|
+
assert.strictEqual(
|
|
363
|
+
error.name,
|
|
364
|
+
'MethodNotAllowed',
|
|
374
365
|
'Removing multiple without option set throws MethodNotAllowed'
|
|
375
|
-
)
|
|
366
|
+
)
|
|
376
367
|
}
|
|
377
368
|
|
|
378
369
|
const params = {
|
|
379
370
|
query: { created: true }
|
|
380
|
-
}
|
|
371
|
+
}
|
|
381
372
|
const dave = await service.create({
|
|
382
373
|
name: 'Dave',
|
|
383
374
|
age: 29,
|
|
384
375
|
created: true
|
|
385
|
-
})
|
|
376
|
+
})
|
|
386
377
|
const david = await service.create({
|
|
387
378
|
name: 'David',
|
|
388
379
|
age: 3,
|
|
389
380
|
created: true
|
|
390
|
-
})
|
|
381
|
+
})
|
|
391
382
|
|
|
392
|
-
service.options.multi = [
|
|
383
|
+
service.options.multi = ['patch']
|
|
393
384
|
|
|
394
|
-
const data = await service.patch(
|
|
395
|
-
|
|
396
|
-
|
|
385
|
+
const data = await service.patch(
|
|
386
|
+
null,
|
|
387
|
+
{
|
|
388
|
+
age: 2
|
|
389
|
+
},
|
|
390
|
+
params
|
|
391
|
+
)
|
|
397
392
|
|
|
398
|
-
assert.strictEqual(data.length, 2, 'returned two entries')
|
|
399
|
-
assert.strictEqual(data[0].age, 2, 'First entry age was updated')
|
|
400
|
-
assert.strictEqual(data[1].age, 2, 'Second entry age was updated')
|
|
393
|
+
assert.strictEqual(data.length, 2, 'returned two entries')
|
|
394
|
+
assert.strictEqual(data[0].age, 2, 'First entry age was updated')
|
|
395
|
+
assert.strictEqual(data[1].age, 2, 'Second entry age was updated')
|
|
401
396
|
|
|
402
|
-
await service.remove(dave[idProp])
|
|
403
|
-
await service.remove(david[idProp])
|
|
404
|
-
})
|
|
397
|
+
await service.remove(dave[idProp])
|
|
398
|
+
await service.remove(david[idProp])
|
|
399
|
+
})
|
|
405
400
|
|
|
406
401
|
test('.patch multiple no pagination', async () => {
|
|
407
402
|
try {
|
|
408
|
-
await service.remove(doug[idProp])
|
|
403
|
+
await service.remove(doug[idProp])
|
|
409
404
|
} catch (error: any) {}
|
|
410
405
|
|
|
411
|
-
const count = 14
|
|
412
|
-
const defaultPaginate = 10
|
|
406
|
+
const count = 14
|
|
407
|
+
const defaultPaginate = 10
|
|
413
408
|
|
|
414
|
-
assert.ok(count > defaultPaginate, 'count is bigger than default pagination')
|
|
409
|
+
assert.ok(count > defaultPaginate, 'count is bigger than default pagination')
|
|
415
410
|
|
|
416
|
-
const multiBefore = service.options.multi
|
|
417
|
-
const paginateBefore = service.options.paginate
|
|
411
|
+
const multiBefore = service.options.multi
|
|
412
|
+
const paginateBefore = service.options.paginate
|
|
418
413
|
|
|
419
|
-
let ids: any[]
|
|
414
|
+
let ids: any[]
|
|
420
415
|
|
|
421
416
|
try {
|
|
422
|
-
service.options.multi = true
|
|
417
|
+
service.options.multi = true
|
|
423
418
|
service.options.paginate = {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
}
|
|
419
|
+
default: defaultPaginate,
|
|
420
|
+
max: 100
|
|
421
|
+
}
|
|
427
422
|
|
|
428
|
-
const emptyItems = await service.find({ paginate: false })
|
|
423
|
+
const emptyItems = await service.find({ paginate: false })
|
|
429
424
|
assert.strictEqual(emptyItems.length, 0, 'no items before')
|
|
430
425
|
|
|
431
426
|
const createdItems = await service.create(
|
|
432
|
-
Array.from(Array(count)).map((_, i) => ({
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
assert.strictEqual(
|
|
439
|
-
|
|
440
|
-
|
|
427
|
+
Array.from(Array(count)).map((_, i) => ({
|
|
428
|
+
name: `name-${i}`,
|
|
429
|
+
age: 3,
|
|
430
|
+
created: true
|
|
431
|
+
}))
|
|
432
|
+
)
|
|
433
|
+
assert.strictEqual(createdItems.length, count, `created ${count} items`)
|
|
434
|
+
ids = createdItems.map((item: any) => item[idProp])
|
|
435
|
+
|
|
436
|
+
const foundItems = await service.find({ paginate: false })
|
|
437
|
+
assert.strictEqual(foundItems.length, count, `created ${count} items`)
|
|
438
|
+
|
|
439
|
+
const foundPaginatedItems = await service.find({})
|
|
441
440
|
assert.strictEqual(foundPaginatedItems.data.length, defaultPaginate, 'found paginated data')
|
|
442
441
|
|
|
443
442
|
const allItems = await service.patch(null, { age: 4 }, { query: { created: true } })
|
|
444
443
|
|
|
445
|
-
assert.strictEqual(allItems.length, count, `patched all ${
|
|
444
|
+
assert.strictEqual(allItems.length, count, `patched all ${count} items`)
|
|
446
445
|
} finally {
|
|
447
|
-
service.options.multi = multiBefore
|
|
448
|
-
service.options.paginate = paginateBefore
|
|
446
|
+
service.options.multi = multiBefore
|
|
447
|
+
service.options.paginate = paginateBefore
|
|
449
448
|
if (ids) {
|
|
450
|
-
await Promise.all(
|
|
451
|
-
ids.map(id => service.remove(id))
|
|
452
|
-
)
|
|
449
|
+
await Promise.all(ids.map((id) => service.remove(id)))
|
|
453
450
|
}
|
|
454
451
|
}
|
|
455
|
-
})
|
|
452
|
+
})
|
|
456
453
|
|
|
457
454
|
test('.patch multi query same', async () => {
|
|
458
|
-
const service = app.service(serviceName)
|
|
459
|
-
const multiBefore = service.options.multi
|
|
455
|
+
const service = app.service(serviceName)
|
|
456
|
+
const multiBefore = service.options.multi
|
|
460
457
|
|
|
461
|
-
service.options.multi = true
|
|
458
|
+
service.options.multi = true
|
|
462
459
|
|
|
463
460
|
const params = {
|
|
464
461
|
query: { age: { $lt: 10 } }
|
|
465
|
-
}
|
|
462
|
+
}
|
|
466
463
|
const dave = await service.create({
|
|
467
464
|
name: 'Dave',
|
|
468
465
|
age: 8,
|
|
469
466
|
created: true
|
|
470
|
-
})
|
|
467
|
+
})
|
|
471
468
|
const david = await service.create({
|
|
472
469
|
name: 'David',
|
|
473
470
|
age: 4,
|
|
474
471
|
created: true
|
|
475
|
-
})
|
|
472
|
+
})
|
|
476
473
|
|
|
477
|
-
const data = await service.patch(
|
|
478
|
-
|
|
479
|
-
|
|
474
|
+
const data = await service.patch(
|
|
475
|
+
null,
|
|
476
|
+
{
|
|
477
|
+
age: 2
|
|
478
|
+
},
|
|
479
|
+
params
|
|
480
|
+
)
|
|
480
481
|
|
|
481
|
-
assert.strictEqual(data.length, 2, 'returned two entries')
|
|
482
|
-
assert.strictEqual(data[0].age, 2, 'First entry age was updated')
|
|
483
|
-
assert.strictEqual(data[1].age, 2, 'Second entry age was updated')
|
|
482
|
+
assert.strictEqual(data.length, 2, 'returned two entries')
|
|
483
|
+
assert.strictEqual(data[0].age, 2, 'First entry age was updated')
|
|
484
|
+
assert.strictEqual(data[1].age, 2, 'Second entry age was updated')
|
|
484
485
|
|
|
485
|
-
await service.remove(dave[idProp])
|
|
486
|
-
await service.remove(david[idProp])
|
|
486
|
+
await service.remove(dave[idProp])
|
|
487
|
+
await service.remove(david[idProp])
|
|
487
488
|
|
|
488
|
-
service.options.multi = multiBefore
|
|
489
|
-
})
|
|
489
|
+
service.options.multi = multiBefore
|
|
490
|
+
})
|
|
490
491
|
|
|
491
492
|
test('.patch multi query changed', async () => {
|
|
492
|
-
const service = app.service(serviceName)
|
|
493
|
-
const multiBefore = service.options.multi
|
|
493
|
+
const service = app.service(serviceName)
|
|
494
|
+
const multiBefore = service.options.multi
|
|
494
495
|
|
|
495
|
-
service.options.multi = true
|
|
496
|
+
service.options.multi = true
|
|
496
497
|
|
|
497
498
|
const params = {
|
|
498
499
|
query: { age: 10 }
|
|
499
|
-
}
|
|
500
|
+
}
|
|
500
501
|
const dave = await service.create({
|
|
501
502
|
name: 'Dave',
|
|
502
503
|
age: 10,
|
|
503
504
|
created: true
|
|
504
|
-
})
|
|
505
|
+
})
|
|
505
506
|
const david = await service.create({
|
|
506
507
|
name: 'David',
|
|
507
508
|
age: 10,
|
|
508
509
|
created: true
|
|
509
|
-
})
|
|
510
|
+
})
|
|
510
511
|
|
|
511
|
-
const data = await service.patch(
|
|
512
|
-
|
|
513
|
-
|
|
512
|
+
const data = await service.patch(
|
|
513
|
+
null,
|
|
514
|
+
{
|
|
515
|
+
age: 2
|
|
516
|
+
},
|
|
517
|
+
params
|
|
518
|
+
)
|
|
514
519
|
|
|
515
|
-
assert.strictEqual(data.length, 2, 'returned two entries')
|
|
516
|
-
assert.strictEqual(data[0].age, 2, 'First entry age was updated')
|
|
517
|
-
assert.strictEqual(data[1].age, 2, 'Second entry age was updated')
|
|
520
|
+
assert.strictEqual(data.length, 2, 'returned two entries')
|
|
521
|
+
assert.strictEqual(data[0].age, 2, 'First entry age was updated')
|
|
522
|
+
assert.strictEqual(data[1].age, 2, 'Second entry age was updated')
|
|
518
523
|
|
|
519
|
-
await service.remove(dave[idProp])
|
|
520
|
-
await service.remove(david[idProp])
|
|
524
|
+
await service.remove(dave[idProp])
|
|
525
|
+
await service.remove(david[idProp])
|
|
521
526
|
|
|
522
|
-
service.options.multi = multiBefore
|
|
523
|
-
})
|
|
527
|
+
service.options.multi = multiBefore
|
|
528
|
+
})
|
|
524
529
|
|
|
525
530
|
test('.patch + NotFound', async () => {
|
|
526
531
|
try {
|
|
527
|
-
await service.patch('568225fbfe21222432e836ff', {
|
|
528
|
-
|
|
532
|
+
await service.patch('568225fbfe21222432e836ff', {
|
|
533
|
+
name: 'PatchDoug'
|
|
534
|
+
})
|
|
535
|
+
throw new Error('Should never get here')
|
|
529
536
|
} catch (error: any) {
|
|
530
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
531
|
-
'Error is a NotFound Feathers error'
|
|
532
|
-
);
|
|
537
|
+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
|
|
533
538
|
}
|
|
534
|
-
})
|
|
539
|
+
})
|
|
535
540
|
|
|
536
541
|
test('.patch + query + NotFound', async () => {
|
|
537
|
-
const dave = await service.create({ name: 'Dave' })
|
|
542
|
+
const dave = await service.create({ name: 'Dave' })
|
|
538
543
|
try {
|
|
539
|
-
await service.patch(
|
|
540
|
-
|
|
541
|
-
{ name: 'PatchedDave' },
|
|
542
|
-
{ query: { name: 'NotDave' } }
|
|
543
|
-
);
|
|
544
|
-
throw new Error('Should never get here');
|
|
544
|
+
await service.patch(dave[idProp], { name: 'PatchedDave' }, { query: { name: 'NotDave' } })
|
|
545
|
+
throw new Error('Should never get here')
|
|
545
546
|
} catch (error: any) {
|
|
546
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
547
|
-
'Error is a NotFound Feathers error'
|
|
548
|
-
);
|
|
547
|
+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
|
|
549
548
|
}
|
|
550
|
-
await service.remove(dave[idProp])
|
|
551
|
-
})
|
|
549
|
+
await service.remove(dave[idProp])
|
|
550
|
+
})
|
|
552
551
|
|
|
553
552
|
test('.patch + id + query id', async () => {
|
|
554
553
|
const alice = await service.create({
|
|
555
554
|
name: 'Alice',
|
|
556
555
|
age: 12
|
|
557
|
-
})
|
|
556
|
+
})
|
|
558
557
|
|
|
559
558
|
try {
|
|
560
|
-
await service.patch(
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
559
|
+
await service.patch(
|
|
560
|
+
doug[idProp],
|
|
561
|
+
{
|
|
562
|
+
age: 33
|
|
563
|
+
},
|
|
564
|
+
{
|
|
565
|
+
query: { [idProp]: alice[idProp] }
|
|
566
|
+
}
|
|
567
|
+
)
|
|
568
|
+
throw new Error('Should never get here')
|
|
566
569
|
} catch (error: any) {
|
|
567
|
-
assert.strictEqual(error.name, 'NotFound',
|
|
568
|
-
'Got a NotFound Feathers error'
|
|
569
|
-
);
|
|
570
|
+
assert.strictEqual(error.name, 'NotFound', 'Got a NotFound Feathers error')
|
|
570
571
|
}
|
|
571
572
|
|
|
572
|
-
await service.remove(alice[idProp])
|
|
573
|
-
})
|
|
574
|
-
})
|
|
573
|
+
await service.remove(alice[idProp])
|
|
574
|
+
})
|
|
575
|
+
})
|
|
575
576
|
|
|
576
577
|
describe('create', () => {
|
|
577
578
|
test('.create', async () => {
|
|
578
579
|
const originalData = {
|
|
579
580
|
name: 'Bill',
|
|
580
581
|
age: 40
|
|
581
|
-
}
|
|
582
|
-
const originalCopy = Object.assign({}, originalData)
|
|
582
|
+
}
|
|
583
|
+
const originalCopy = Object.assign({}, originalData)
|
|
583
584
|
|
|
584
|
-
const data = await service.create(originalData)
|
|
585
|
+
const data = await service.create(originalData)
|
|
585
586
|
|
|
586
|
-
assert.deepStrictEqual(originalData, originalCopy,
|
|
587
|
-
|
|
588
|
-
)
|
|
589
|
-
assert.ok(data instanceof Object, 'data is an object');
|
|
590
|
-
assert.strictEqual(data.name, 'Bill', 'data.name matches');
|
|
587
|
+
assert.deepStrictEqual(originalData, originalCopy, 'original data was not modified')
|
|
588
|
+
assert.ok(data instanceof Object, 'data is an object')
|
|
589
|
+
assert.strictEqual(data.name, 'Bill', 'data.name matches')
|
|
591
590
|
|
|
592
|
-
await service.remove(data[idProp])
|
|
593
|
-
})
|
|
591
|
+
await service.remove(data[idProp])
|
|
592
|
+
})
|
|
594
593
|
|
|
595
594
|
test('.create + $select', async () => {
|
|
596
595
|
const originalData = {
|
|
597
596
|
name: 'William',
|
|
598
597
|
age: 23
|
|
599
|
-
}
|
|
598
|
+
}
|
|
600
599
|
|
|
601
600
|
const data = await service.create(originalData, {
|
|
602
|
-
query: { $select: [
|
|
603
|
-
})
|
|
601
|
+
query: { $select: ['name'] }
|
|
602
|
+
})
|
|
604
603
|
|
|
605
|
-
assert.strictEqual(data.name, 'William', 'data.name matches')
|
|
606
|
-
assert.ok(!data.age, 'data.age is falsy')
|
|
604
|
+
assert.strictEqual(data.name, 'William', 'data.name matches')
|
|
605
|
+
assert.ok(!data.age, 'data.age is falsy')
|
|
607
606
|
|
|
608
|
-
await service.remove(data[idProp])
|
|
609
|
-
})
|
|
607
|
+
await service.remove(data[idProp])
|
|
608
|
+
})
|
|
610
609
|
|
|
611
610
|
test('.create multi', async () => {
|
|
612
611
|
try {
|
|
613
|
-
await service.create([], {})
|
|
614
|
-
throw new Error('Should never get here')
|
|
612
|
+
await service.create([], {})
|
|
613
|
+
throw new Error('Should never get here')
|
|
615
614
|
} catch (error: any) {
|
|
616
|
-
assert.strictEqual(
|
|
615
|
+
assert.strictEqual(
|
|
616
|
+
error.name,
|
|
617
|
+
'MethodNotAllowed',
|
|
617
618
|
'Removing multiple without option set throws MethodNotAllowed'
|
|
618
|
-
)
|
|
619
|
+
)
|
|
619
620
|
}
|
|
620
621
|
|
|
621
622
|
const items = [
|
|
@@ -627,83 +628,77 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
|
|
|
627
628
|
name: 'Herald',
|
|
628
629
|
age: 18
|
|
629
630
|
}
|
|
630
|
-
]
|
|
631
|
+
]
|
|
631
632
|
|
|
632
|
-
service.options.multi = [
|
|
633
|
+
service.options.multi = ['create', 'patch']
|
|
633
634
|
|
|
634
|
-
const data = await service.create(items)
|
|
635
|
+
const data = await service.create(items)
|
|
635
636
|
|
|
636
|
-
assert.ok(Array.isArray(data), 'data is an array')
|
|
637
|
-
assert.ok(typeof data[0][idProp] !== 'undefined', 'id is set')
|
|
638
|
-
assert.strictEqual(data[0].name, 'Gerald', 'first name matches')
|
|
639
|
-
assert.ok(typeof data[1][idProp] !== 'undefined', 'id is set')
|
|
640
|
-
assert.strictEqual(data[1].name, 'Herald', 'second name macthes')
|
|
637
|
+
assert.ok(Array.isArray(data), 'data is an array')
|
|
638
|
+
assert.ok(typeof data[0][idProp] !== 'undefined', 'id is set')
|
|
639
|
+
assert.strictEqual(data[0].name, 'Gerald', 'first name matches')
|
|
640
|
+
assert.ok(typeof data[1][idProp] !== 'undefined', 'id is set')
|
|
641
|
+
assert.strictEqual(data[1].name, 'Herald', 'second name macthes')
|
|
641
642
|
|
|
642
|
-
await service.remove(data[0][idProp])
|
|
643
|
-
await service.remove(data[1][idProp])
|
|
644
|
-
})
|
|
645
|
-
})
|
|
643
|
+
await service.remove(data[0][idProp])
|
|
644
|
+
await service.remove(data[1][idProp])
|
|
645
|
+
})
|
|
646
|
+
})
|
|
646
647
|
|
|
647
|
-
describe(
|
|
648
|
-
let throwing: any
|
|
648
|
+
describe("doesn't call public methods internally", () => {
|
|
649
|
+
let throwing: any
|
|
649
650
|
|
|
650
651
|
before(() => {
|
|
651
652
|
throwing = Object.assign(Object.create(app.service(serviceName)), {
|
|
652
|
-
get store
|
|
653
|
-
return app.service(serviceName).store
|
|
653
|
+
get store() {
|
|
654
|
+
return app.service(serviceName).store
|
|
654
655
|
},
|
|
655
656
|
|
|
656
|
-
find
|
|
657
|
-
throw new Error('find method called')
|
|
657
|
+
find() {
|
|
658
|
+
throw new Error('find method called')
|
|
658
659
|
},
|
|
659
|
-
get
|
|
660
|
-
throw new Error('get method called')
|
|
660
|
+
get() {
|
|
661
|
+
throw new Error('get method called')
|
|
661
662
|
},
|
|
662
|
-
create
|
|
663
|
-
throw new Error('create method called')
|
|
663
|
+
create() {
|
|
664
|
+
throw new Error('create method called')
|
|
664
665
|
},
|
|
665
|
-
update
|
|
666
|
-
throw new Error('update method called')
|
|
666
|
+
update() {
|
|
667
|
+
throw new Error('update method called')
|
|
667
668
|
},
|
|
668
|
-
patch
|
|
669
|
-
throw new Error('patch method called')
|
|
669
|
+
patch() {
|
|
670
|
+
throw new Error('patch method called')
|
|
670
671
|
},
|
|
671
|
-
remove
|
|
672
|
-
throw new Error('remove method called')
|
|
672
|
+
remove() {
|
|
673
|
+
throw new Error('remove method called')
|
|
673
674
|
}
|
|
674
|
-
})
|
|
675
|
-
})
|
|
675
|
+
})
|
|
676
|
+
})
|
|
676
677
|
|
|
677
|
-
test('internal .find', () => app.service(serviceName).find.call(throwing))
|
|
678
|
+
test('internal .find', () => app.service(serviceName).find.call(throwing))
|
|
678
679
|
|
|
679
|
-
test('internal .get', () =>
|
|
680
|
-
service.get.call(throwing, doug[idProp])
|
|
681
|
-
);
|
|
680
|
+
test('internal .get', () => service.get.call(throwing, doug[idProp]))
|
|
682
681
|
|
|
683
682
|
test('internal .create', async () => {
|
|
684
683
|
const bob = await service.create.call(throwing, {
|
|
685
684
|
name: 'Bob',
|
|
686
685
|
age: 25
|
|
687
|
-
})
|
|
686
|
+
})
|
|
688
687
|
|
|
689
|
-
await service.remove(bob[idProp])
|
|
690
|
-
})
|
|
688
|
+
await service.remove(bob[idProp])
|
|
689
|
+
})
|
|
691
690
|
|
|
692
691
|
test('internal .update', () =>
|
|
693
692
|
service.update.call(throwing, doug[idProp], {
|
|
694
693
|
name: 'Dougler'
|
|
695
|
-
})
|
|
696
|
-
);
|
|
694
|
+
}))
|
|
697
695
|
|
|
698
696
|
test('internal .patch', () =>
|
|
699
697
|
service.patch.call(throwing, doug[idProp], {
|
|
700
698
|
name: 'PatchDoug'
|
|
701
|
-
})
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
});
|
|
708
|
-
});
|
|
709
|
-
};
|
|
699
|
+
}))
|
|
700
|
+
|
|
701
|
+
test('internal .remove', () => service.remove.call(throwing, doug[idProp]))
|
|
702
|
+
})
|
|
703
|
+
})
|
|
704
|
+
}
|