Skip to content

Commit de7184d

Browse files
committed
Add test for merged options
1 parent b7f0e80 commit de7184d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

test/seam/connect/client.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,40 @@ test('SeamHttp: constructor returns instance that uses client', async (t) => {
2626
t.is(device.workspace_id, seed.seed_workspace_1)
2727
t.is(device.device_id, seed.august_device_1)
2828
})
29+
30+
test('SeamHttp: merges axiosOptions when creating client', async (t) => {
31+
const { seed, endpoint } = await getTestServer(t)
32+
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, {
33+
endpoint,
34+
axiosOptions: {
35+
transformResponse: [
36+
(data) =>
37+
JSON.parse(
38+
data.replaceAll(seed.august_device_1, 'transformed-device-id'),
39+
),
40+
],
41+
},
42+
})
43+
const device = await seam.devices.get({
44+
device_id: seed.august_device_1,
45+
})
46+
t.is(device.workspace_id, seed.seed_workspace_1)
47+
t.is(device.device_id, 'transformed-device-id')
48+
})
49+
50+
test('SeamHttp: merges axios headers when creating client', async (t) => {
51+
const { seed, endpoint } = await getTestServer(t)
52+
const seam = SeamHttp.fromApiKey('seam_invalidapikey_token', {
53+
endpoint,
54+
axiosOptions: {
55+
headers: {
56+
Authorization: `Bearer ${seed.seam_apikey1_token}`,
57+
},
58+
},
59+
})
60+
const device = await seam.devices.get({
61+
device_id: seed.august_device_1,
62+
})
63+
t.is(device.workspace_id, seed.seed_workspace_1)
64+
t.is(device.device_id, seed.august_device_1)
65+
})

0 commit comments

Comments
 (0)