Skip to content

Commit 5a75eae

Browse files
committed
Move test for SeamHttpRequest into its own file
1 parent bc1340c commit 5a75eae

File tree

2 files changed

+35
-29
lines changed

2 files changed

+35
-29
lines changed

test/seam/connect/client.test.ts

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -164,32 +164,3 @@ test.failing(
164164
t.true(workspaces.length > 0)
165165
},
166166
)
167-
168-
test('SeamHttp: request methods return a SeamHttpRequest object', async (t) => {
169-
const { seed, endpoint } = await getTestServer(t)
170-
const seam = new SeamHttp({
171-
client: SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint }).client,
172-
})
173-
174-
const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 })
175-
176-
t.true(deviceRequest instanceof SeamHttpRequest)
177-
t.is(deviceRequest.url, '/devices/get')
178-
t.deepEqual(deviceRequest.data, {
179-
device_id: seed.august_device_1,
180-
})
181-
t.is(deviceRequest.resourceKey, 'device')
182-
const device = await deviceRequest
183-
t.is(device.workspace_id, seed.seed_workspace_1)
184-
t.is(device.device_id, seed.august_device_1)
185-
186-
// Ensure that the type of the response is correct.
187-
type Expected = ResponseFromSeamHttpRequest<typeof deviceRequest>
188-
189-
const validDeviceType: Expected['device_type'] = 'august_lock'
190-
t.truthy(validDeviceType)
191-
192-
// @ts-expect-error because it's an invalid device type.
193-
const invalidDeviceType: Expected['device_type'] = 'invalid_device_type'
194-
t.truthy(invalidDeviceType)
195-
})
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import test from 'ava'
2+
import { getTestServer } from 'fixtures/seam/connect/api.js'
3+
4+
import { SeamHttp } from '@seamapi/http/connect'
5+
import {
6+
SeamHttpRequest,
7+
type ResponseFromSeamHttpRequest,
8+
} from 'lib/seam/connect/seam-http-request.js'
9+
10+
test('serializes array params when undefined', async (t) => {
11+
const { seed, endpoint } = await getTestServer(t)
12+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
13+
14+
const deviceRequest = seam.devices.get({ device_id: seed.august_device_1 })
15+
16+
t.true(deviceRequest instanceof SeamHttpRequest)
17+
t.is(deviceRequest.url, '/devices/get')
18+
t.deepEqual(deviceRequest.data, {
19+
device_id: seed.august_device_1,
20+
})
21+
t.is(deviceRequest.resourceKey, 'device')
22+
const device = await deviceRequest
23+
t.is(device.workspace_id, seed.seed_workspace_1)
24+
t.is(device.device_id, seed.august_device_1)
25+
26+
// Ensure that the type of the response is correct.
27+
type Expected = ResponseFromSeamHttpRequest<typeof deviceRequest>
28+
29+
const validDeviceType: Expected['device_type'] = 'august_lock'
30+
t.truthy(validDeviceType)
31+
32+
// @ts-expect-error because it's an invalid device type.
33+
const invalidDeviceType: Expected['device_type'] = 'invalid_device_type'
34+
t.truthy(invalidDeviceType)
35+
})

0 commit comments

Comments
 (0)