diff --git a/src/routes/filterwheel.ts b/src/routes/filterwheel.ts index bf6e594..5931d4f 100644 --- a/src/routes/filterwheel.ts +++ b/src/routes/filterwheel.ts @@ -26,5 +26,16 @@ export const filterwheel = ( const url = new URL('filterwheel/connected', base) return dispatchRequest(url, init, headers) } + }, + { + name: 'getPosition', + action: < + T = { + position: number + } + >() => { + const url = new URL('filterwheel/position', base) + return dispatchRequest(url, init, headers) + } } ] as const diff --git a/tests/filterwheelRoutes.spec.ts b/tests/filterwheelRoutes.spec.ts index d076391..39f7ca8 100644 --- a/tests/filterwheelRoutes.spec.ts +++ b/tests/filterwheelRoutes.spec.ts @@ -25,5 +25,13 @@ suite('@observerly/hyper Fiber API Filterwheel Client', () => { if (!isDataResult(isConnected)) return expect(isConnected).toStrictEqual({ connected: true }) }) + + it('should be able to determine the position of the filterwheel', async () => { + const client = setupClient(getURL('/api/v1/')) + const position = await client.filterwheel.getPosition() + expect(isDataResult(position)).toBe(true) + if (!isDataResult(position)) return + expect(position).toStrictEqual({ position: 0 }) + }) }) }) diff --git a/tests/mocks/filterwheel.ts b/tests/mocks/filterwheel.ts index 0537159..84aa915 100644 --- a/tests/mocks/filterwheel.ts +++ b/tests/mocks/filterwheel.ts @@ -21,5 +21,14 @@ export const filterwheelHandlers: Handler[] = [ connected: true } }) + }, + { + method: 'GET', + url: '/api/v1/filterwheel/position', + handler: eventHandler(_event => { + return { + position: 0 + } + }) } ]