diff --git a/src/routes/camera.ts b/src/routes/camera.ts index 0b2ccee..832edbe 100644 --- a/src/routes/camera.ts +++ b/src/routes/camera.ts @@ -202,5 +202,13 @@ export const camera = (base: URL, init?: RequestInit, headers?: () => Promise() => { + const url = new URL('camera/exposure', base) + + return dispatchRequest(url, { ...init, method: 'DELETE' }, headers) + } } ] as const diff --git a/tests/camera.spec.ts b/tests/camera.spec.ts index db04816..004f2fb 100644 --- a/tests/camera.spec.ts +++ b/tests/camera.spec.ts @@ -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({}) + }) }) }) diff --git a/tests/mocks/camera.ts b/tests/mocks/camera.ts index 5672ee2..bb98e1e 100644 --- a/tests/mocks/camera.ts +++ b/tests/mocks/camera.ts @@ -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' @@ -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 + } + : {} }) } ]