From 05c9e3c6f1ebba6ebec39396ef1c6bb38797489b Mon Sep 17 00:00:00 2001 From: "Michael J. Roberts" Date: Tue, 18 Apr 2023 16:08:05 +0100 Subject: [PATCH] feat: Added client.telescope.getConfiguration() route handler. feat: Added client.telescope.getConfiguration() route handler. Includes associated test suite for module export definition and expected output from API route. --- src/routes/telescope.ts | 13 +++++++++++++ tests/mocks/telescope.ts | 11 +++++++++++ tests/telescopeRoutes.spec.ts | 9 +++++++++ 3 files changed, 33 insertions(+) diff --git a/src/routes/telescope.ts b/src/routes/telescope.ts index 4158d9b..ea52e9c 100644 --- a/src/routes/telescope.ts +++ b/src/routes/telescope.ts @@ -48,6 +48,19 @@ export const telescope = ( const url = new URL('telescope/tracking', base) return dispatchRequest(url, init, headers) } + }, + { + name: 'getConfiguration', + action: < + T = { + apertureArea: number + apertureDiameter: number + focalLength: number + } + >() => { + const url = new URL('telescope/config', base) + return dispatchRequest(url, init, headers) + } } ] as const diff --git a/tests/mocks/telescope.ts b/tests/mocks/telescope.ts index 551e250..a6c2672 100644 --- a/tests/mocks/telescope.ts +++ b/tests/mocks/telescope.ts @@ -39,6 +39,17 @@ export const telescopeHandlers: Handler[] = [ tracking: false } }) + }, + { + method: 'GET', + url: '/api/v1/telescope/config', + handler: eventHandler(_event => { + return { + apertureArea: 0.0269, + apertureDiameter: 0.0269, + focalLength: 1.26 + } + }) } ] diff --git a/tests/telescopeRoutes.spec.ts b/tests/telescopeRoutes.spec.ts index a200d78..4e8627e 100644 --- a/tests/telescopeRoutes.spec.ts +++ b/tests/telescopeRoutes.spec.ts @@ -33,5 +33,14 @@ suite('@observerly/hyper Fiber API Telescope Client', () => { const { tracking } = await client.telescope.isTracking() expect(tracking).toBe(false) }) + + it('should be able to determine the configuration of the telescope', async () => { + const client = setupClient(getURL('/api/v1/')) + const config = await client.telescope.getConfiguration() + const { apertureArea, apertureDiameter, focalLength } = config + expect(apertureArea).toBe(0.0269) + expect(apertureDiameter).toBe(0.0269) + expect(focalLength).toBe(1.26) + }) }) })