Skip to content
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
8 changes: 8 additions & 0 deletions src/routes/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,13 @@ export const camera = (base: URL, init?: RequestInit, headers?: () => Promise<He
data
)
}
},
{
name: 'stopExposure',
action: <T = {}>() => {
const url = new URL('camera/exposure', base)

return dispatchRequest<T>(url, { ...init, method: 'DELETE' }, headers)
}
}
] as const
8 changes: 8 additions & 0 deletions tests/camera.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,13 @@ suite('@observerly/hyper Fiber API Observing Camera Client', () => {
light: true
})
})

it('should be able to stop an exposure on the camera', async () => {
const client = setupClient(getURL('/api/v1/'))
const status = await client.camera.stopExposure()
expect(isDataResult(status)).toBe(true)
if (!isDataResult(status)) return
expect(status).toStrictEqual({})
})
})
})
18 changes: 10 additions & 8 deletions tests/mocks/camera.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ export const cameraHandlers: Handler[] = [
})
},
{
method: ['PUT'],
method: ['PUT', 'DELETE'],
url: '/api/v1/camera/exposure',
handler: eventHandler(async event => {
const method = getMethod(event)

if (method !== 'PUT') {
if (method !== 'PUT' && method !== 'DELETE') {
return new Response('Method Not Allowed', {
status: 405,
statusText: 'Method Not Allowed'
Expand All @@ -201,12 +201,14 @@ export const cameraHandlers: Handler[] = [
})
}

return {
duration: 300,
flat: false,
dark: false,
light: true
}
return method === 'PUT'
? {
duration: 300,
flat: false,
dark: false,
light: true
}
: {}
})
}
]