Skip to content

Commit

Permalink
test(adapter-tests): NotFound integer & add remove:NotFound tests
Browse files Browse the repository at this point in the history
  • Loading branch information
fratzinger committed May 13, 2024
1 parent 01bc333 commit 8322f38
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/adapter-tests/src/declarations.ts
Expand Up @@ -28,18 +28,22 @@ export type AdapterMethodsTestName =
| '.get + $select'
| '.get + id + query'
| '.get + NotFound'
| '.get + NotFound (integer)'
| '.get + id + query id'
| '.find'
| '.remove'
| '.remove + $select'
| '.remove + id + query'
| '.remove + NotFound'
| '.remove + NotFound (integer)'
| '.remove + multi'
| '.remove + multi no pagination'
| '.remove + id + query id'
| '.update'
| '.update + $select'
| '.update + id + query'
| '.update + NotFound'
| '.update + NotFound (integer)'
| '.update + query + NotFound'
| '.update + id + query id'
| '.patch'
Expand All @@ -50,6 +54,7 @@ export type AdapterMethodsTestName =
| '.patch multi query same'
| '.patch multi query changed'
| '.patch + NotFound'
| '.patch + NotFound (integer)'
| '.patch + query + NotFound'
| '.patch + id + query id'
| '.create'
Expand Down
49 changes: 49 additions & 0 deletions packages/adapter-tests/src/methods.ts
Expand Up @@ -59,6 +59,15 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
}
})

test('.get + NotFound (integer)', async () => {
try {
await service.get(123456789)
throw new Error('Should never get here')
} catch (error: any) {
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
}
})

test('.get + id + query id', async () => {
const alice = await service.create({
name: 'Alice',
Expand Down Expand Up @@ -115,6 +124,24 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
}
})

test('.remove + NotFound', async () => {
try {
await service.remove('568225fbfe21222432e836ff')
throw new Error('Should never get here')
} catch (error: any) {
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
}
})

test('.remove + NotFound (integer)', async () => {
try {
await service.remove(123456789)
throw new Error('Should never get here')
} catch (error: any) {
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
}
})

test('.remove + multi', async () => {
try {
await service.remove(null)
Expand Down Expand Up @@ -278,6 +305,17 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
}
})

test('.update + NotFound (integer)', async () => {
try {
await service.update(123456789, {
name: 'NotFound'
})
throw new Error('Should never get here')
} catch (error: any) {
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
}
})

test('.update + query + NotFound', async () => {
const dave = await service.create({ name: 'Dave' })
try {
Expand Down Expand Up @@ -541,6 +579,17 @@ export default (test: AdapterMethodsTest, app: any, _errors: any, serviceName: s
}
})

test('.patch + NotFound (integer)', async () => {
try {
await service.patch(123456789, {
name: 'PatchDoug'
})
throw new Error('Should never get here')
} catch (error: any) {
assert.strictEqual(error.name, 'NotFound', 'Error is a NotFound Feathers error')
}
})

test('.patch + query + NotFound', async () => {
const dave = await service.create({ name: 'Dave' })
try {
Expand Down

0 comments on commit 8322f38

Please sign in to comment.