Skip to content

Commit a02febb

Browse files
authored
test(adapter-tests): NotFound integer & add remove:NotFound tests (#3486)
1 parent c7b0111 commit a02febb

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

packages/adapter-tests/src/declarations.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,22 @@ export type AdapterMethodsTestName =
2828
| '.get + $select'
2929
| '.get + id + query'
3030
| '.get + NotFound'
31+
| '.get + NotFound (integer)'
3132
| '.get + id + query id'
3233
| '.find'
3334
| '.remove'
3435
| '.remove + $select'
3536
| '.remove + id + query'
37+
| '.remove + NotFound'
38+
| '.remove + NotFound (integer)'
3639
| '.remove + multi'
3740
| '.remove + multi no pagination'
3841
| '.remove + id + query id'
3942
| '.update'
4043
| '.update + $select'
4144
| '.update + id + query'
4245
| '.update + NotFound'
46+
| '.update + NotFound (integer)'
4347
| '.update + query + NotFound'
4448
| '.update + id + query id'
4549
| '.patch'
@@ -50,6 +54,7 @@ export type AdapterMethodsTestName =
5054
| '.patch multi query same'
5155
| '.patch multi query changed'
5256
| '.patch + NotFound'
57+
| '.patch + NotFound (integer)'
5358
| '.patch + query + NotFound'
5459
| '.patch + id + query id'
5560
| '.create'

packages/adapter-tests/src/methods.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
5959
}
6060
})
6161

62+
test('.get + NotFound (integer)', async () => {
63+
try {
64+
await service.get(123456789)
65+
throw new Error('Should never get here')
66+
} catch (error: any) {
67+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
68+
}
69+
})
70+
6271
test('.get + id + query id', async () => {
6372
const alice = await service.create({
6473
name: 'Alice',
@@ -115,6 +124,24 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
115124
}
116125
})
117126

127+
test('.remove + NotFound', async () => {
128+
try {
129+
await service.remove('568225fbfe21222432e836ff')
130+
throw new Error('Should never get here')
131+
} catch (error: any) {
132+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
133+
}
134+
})
135+
136+
test('.remove + NotFound (integer)', async () => {
137+
try {
138+
await service.remove(123456789)
139+
throw new Error('Should never get here')
140+
} catch (error: any) {
141+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
142+
}
143+
})
144+
118145
test('.remove + multi', async () => {
119146
try {
120147
await service.remove(null)
@@ -278,6 +305,17 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
278305
}
279306
})
280307

308+
test('.update + NotFound (integer)', async () => {
309+
try {
310+
await service.update(123456789, {
311+
name: 'NotFound'
312+
})
313+
throw new Error('Should never get here')
314+
} catch (error: any) {
315+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
316+
}
317+
})
318+
281319
test('.update + query + NotFound', async () => {
282320
const dave = await service.create({ name: 'Dave' })
283321
try {
@@ -541,6 +579,17 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
541579
}
542580
})
543581

582+
test('.patch + NotFound (integer)', async () => {
583+
try {
584+
await service.patch(123456789, {
585+
name: 'PatchDoug'
586+
})
587+
throw new Error('Should never get here')
588+
} catch (error: any) {
589+
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
590+
}
591+
})
592+
544593
test('.patch + query + NotFound', async () => {
545594
const dave = await service.create({ name: 'Dave' })
546595
try {

0 commit comments

Comments
 (0)