@@ -3,6 +3,12 @@ import { getTestServer } from 'fixtures/seam/connect/api.js'
33
44import { SeamHttp } from '@seamapi/http/connect'
55
6+ import type {
7+ DevicesGetResponse ,
8+ DevicesListBody ,
9+ DevicesListResponse ,
10+ } from 'lib/seam/connect/routes/devices.js'
11+
612test ( 'SeamHttp: fromClient returns instance that uses client' , async ( t ) => {
713 const { seed, endpoint } = await getTestServer ( t )
814 const seam = SeamHttp . fromClient (
@@ -27,6 +33,43 @@ test('SeamHttp: constructor returns instance that uses client', async (t) => {
2733 t . is ( device . device_id , seed . august_device_1 )
2834} )
2935
36+ test ( 'SeamHttp: can use client to make requests' , async ( t ) => {
37+ const { seed, endpoint } = await getTestServer ( t )
38+ const seam = new SeamHttp ( {
39+ client : SeamHttp . fromApiKey ( seed . seam_apikey1_token , { endpoint } ) . client ,
40+ } )
41+ const {
42+ data : { device } ,
43+ status,
44+ } = await seam . client . get < DevicesGetResponse > ( '/devices/get' , {
45+ params : { device_id : seed . august_device_1 } ,
46+ } )
47+ t . is ( status , 200 )
48+ t . is ( device . workspace_id , seed . seed_workspace_1 )
49+ t . is ( device . device_id , seed . august_device_1 )
50+ } )
51+
52+ test ( 'SeamHttp: client serializes array params' , async ( t ) => {
53+ const { seed, endpoint } = await getTestServer ( t )
54+ const seam = new SeamHttp ( {
55+ client : SeamHttp . fromApiKey ( seed . seam_apikey1_token , { endpoint } ) . client ,
56+ } )
57+ const params : DevicesListBody = {
58+ device_ids : [ seed . august_device_1 ] ,
59+ }
60+ const {
61+ data : { devices } ,
62+ status,
63+ } = await seam . client . get < DevicesListResponse > ( '/devices/list' , {
64+ params,
65+ } )
66+ t . is ( status , 200 )
67+ t . is ( devices . length , 1 )
68+ const [ device ] = devices
69+ t . is ( device ?. workspace_id , seed . seed_workspace_1 )
70+ t . is ( device ?. device_id , seed . august_device_1 )
71+ } )
72+
3073test ( 'SeamHttp: merges axiosOptions when creating client' , async ( t ) => {
3174 const { seed, endpoint } = await getTestServer ( t )
3275 const seam = SeamHttp . fromApiKey ( seed . seam_apikey1_token , {
0 commit comments