@@ -4,11 +4,11 @@ import type {
4
4
DeviceProfile ,
5
5
DeviceProfilesEndpoint ,
6
6
LocaleReference ,
7
- SmartThingsClient ,
8
7
} from '@smartthings/core-sdk'
9
8
10
9
import type { WithLocales } from '../../../../lib/api-helpers.js'
11
- import { createChooseFn , ChooseFunction } from '../../../../lib/command/util/util-util.js'
10
+ import type { APICommand } from '../../../../lib/command/api-command.js'
11
+ import { type createChooseFn , ChooseFunction } from '../../../../lib/command/util/util-util.js'
12
12
13
13
14
14
const createChooseFnMock = jest . fn < typeof createChooseFn < DeviceProfile & WithLocales > > ( )
@@ -29,12 +29,14 @@ describe('chooseDeviceProfileFn', () => {
29
29
const locales = [ { tag : 'es_MX' } , { tag : 'en_CA' } , { tag : 'fr_CA' } ] as LocaleReference [ ]
30
30
const apiDeviceProfilesListLocalesMock = jest . fn < typeof DeviceProfilesEndpoint . prototype . listLocales > ( )
31
31
. mockResolvedValue ( locales )
32
- const client = {
33
- deviceProfiles : {
34
- list : apiDeviceProfilesListMock ,
35
- listLocales : apiDeviceProfilesListLocalesMock ,
32
+ const command = {
33
+ client : {
34
+ deviceProfiles : {
35
+ list : apiDeviceProfilesListMock ,
36
+ listLocales : apiDeviceProfilesListLocalesMock ,
37
+ } ,
36
38
} ,
37
- } as unknown as SmartThingsClient
39
+ } as unknown as APICommand
38
40
39
41
it ( 'uses correct endpoint to list device profiles' , async ( ) => {
40
42
const chooseDeviceProfile = chooseDeviceProfileFn ( )
@@ -51,7 +53,7 @@ describe('chooseDeviceProfileFn', () => {
51
53
52
54
const listItems = createChooseFnMock . mock . calls [ 0 ] [ 1 ]
53
55
54
- expect ( await listItems ( client ) ) . toBe ( deviceProfiles )
56
+ expect ( await listItems ( command ) ) . toBe ( deviceProfiles )
55
57
56
58
expect ( apiDeviceProfilesListMock ) . toHaveBeenCalledExactlyOnceWith ( )
57
59
@@ -73,7 +75,7 @@ describe('chooseDeviceProfileFn', () => {
73
75
74
76
const listItems = createChooseFnMock . mock . calls [ 0 ] [ 1 ]
75
77
76
- expect ( await listItems ( client ) ) . toStrictEqual ( [ {
78
+ expect ( await listItems ( command ) ) . toStrictEqual ( [ {
77
79
id : 'device-profile-id' ,
78
80
locales : 'en_CA, es_MX, fr_CA' ,
79
81
} ] )
@@ -99,7 +101,7 @@ describe('chooseDeviceProfileFn', () => {
99
101
const listItems = createChooseFnMock . mock . calls [ 0 ] [ 1 ]
100
102
apiDeviceProfilesListLocalesMock . mockImplementationOnce ( ( ) => { throw { message : 'status code 404' } } )
101
103
102
- expect ( await listItems ( client ) ) . toStrictEqual ( [ {
104
+ expect ( await listItems ( command ) ) . toStrictEqual ( [ {
103
105
id : 'device-profile-id' ,
104
106
} ] )
105
107
@@ -123,7 +125,7 @@ describe('chooseDeviceProfileFn', () => {
123
125
const listItems = createChooseFnMock . mock . calls [ 0 ] [ 1 ]
124
126
apiDeviceProfilesListLocalesMock . mockImplementationOnce ( ( ) => { throw Error ( 'other error' ) } )
125
127
126
- await expect ( listItems ( client ) ) . rejects . toThrow ( 'other error' )
128
+ await expect ( listItems ( command ) ) . rejects . toThrow ( 'other error' )
127
129
128
130
expect ( apiDeviceProfilesListMock ) . toHaveBeenCalledExactlyOnceWith ( )
129
131
expect ( apiDeviceProfilesListLocalesMock ) . toHaveBeenCalledExactlyOnceWith ( 'device-profile-id' )
0 commit comments