@@ -3,6 +3,12 @@ import { getTestServer } from 'fixtures/seam/connect/api.js'
3
3
4
4
import { SeamHttp } from '@seamapi/http/connect'
5
5
6
+ import type {
7
+ DevicesGetResponse ,
8
+ DevicesListBody ,
9
+ DevicesListResponse ,
10
+ } from 'lib/seam/connect/routes/devices.js'
11
+
6
12
test ( 'SeamHttp: fromClient returns instance that uses client' , async ( t ) => {
7
13
const { seed, endpoint } = await getTestServer ( t )
8
14
const seam = SeamHttp . fromClient (
@@ -27,6 +33,43 @@ test('SeamHttp: constructor returns instance that uses client', async (t) => {
27
33
t . is ( device . device_id , seed . august_device_1 )
28
34
} )
29
35
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
+
30
73
test ( 'SeamHttp: merges axiosOptions when creating client' , async ( t ) => {
31
74
const { seed, endpoint } = await getTestServer ( t )
32
75
const seam = SeamHttp . fromApiKey ( seed . seam_apikey1_token , {
0 commit comments