Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(adapter-tests): NotFound integer & add remove:NotFound tests #3486

Merged
merged 1 commit into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading