Skip to content

Commit 255586d

Browse files
committed
Add serialization test
1 parent 4eea923 commit 255586d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import test from 'ava'
2+
import { getTestServer } from 'fixtures/seam/connect/api.js'
3+
4+
import { SeamHttp } from '@seamapi/http/connect'
5+
6+
test('serializes array params when undefined', async (t) => {
7+
const { seed, endpoint } = await getTestServer(t)
8+
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
9+
const devices = await client.devices.list({
10+
device_ids: undefined,
11+
})
12+
t.is(devices.length, 4)
13+
})
14+
15+
test('serializes array params when empty', async (t) => {
16+
const { seed, endpoint } = await getTestServer(t)
17+
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
18+
const devices = await client.devices.list({
19+
device_ids: [],
20+
})
21+
t.is(devices.length, 0)
22+
})
23+
24+
test('serializes array params when non-empty', async (t) => {
25+
const { seed, endpoint } = await getTestServer(t)
26+
const client = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
27+
const devices = await client.devices.list({
28+
device_ids: [seed.august_device_1, seed.ecobee_device_1],
29+
})
30+
t.is(devices.length, 2)
31+
t.true(devices.some((d) => d.device_id === seed.august_device_1))
32+
t.true(devices.some((d) => d.device_id === seed.ecobee_device_1))
33+
})

0 commit comments

Comments
 (0)