Skip to content

Commit

Permalink
test(adapter-tests): NotFound integer & add remove:NotFound tests (#3486
Browse files Browse the repository at this point in the history
)
  • Loading branch information
fratzinger authored May 30, 2024
1 parent c7b0111 commit a02febb
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 a02febb

Please sign in to comment.