@@ -100,3 +100,83 @@ test('simctl version', (t) => {
100100 const retObj = simctl . simctl_version ( )
101101 t . assert . ok ( retObj [ 0 ] >= 400 )
102102} )
103+
104+ test ( 'simctl list' , async ( ctx ) => {
105+ ctx . beforeEach ( ( t ) => {
106+ spawnMock . mock . resetCalls ( )
107+
108+ t . mock . method ( console , 'error' , ( ) => { } )
109+ } )
110+
111+ await ctx . test ( 'with no arguments' , ( t ) => {
112+ t . assert ||= require ( 'node:assert' )
113+
114+ spawnMock . mock . mockImplementationOnce ( ( ) => {
115+ return { status : 0 , stdout : '{}' }
116+ } )
117+
118+ const retObj = simctl . list ( )
119+ t . assert . deepEqual ( spawnMock . mock . calls [ 0 ] . arguments [ 1 ] , [ 'simctl' , 'list' , '--json' ] )
120+ t . assert . deepEqual ( retObj . json , { } )
121+ } )
122+
123+ await ctx . test ( 'with devices arguments' , ( t ) => {
124+ t . assert ||= require ( 'node:assert' )
125+
126+ spawnMock . mock . mockImplementationOnce ( ( ) => {
127+ return { status : 0 , stdout : '{}' }
128+ } )
129+
130+ const retObj = simctl . list ( { devices : true } )
131+ t . assert . deepEqual ( spawnMock . mock . calls [ 0 ] . arguments [ 1 ] , [ 'simctl' , 'list' , 'devices' , '--json' ] )
132+ t . assert . deepEqual ( retObj . json , { } )
133+ } )
134+
135+ await ctx . test ( 'with devicetypes arguments' , ( t ) => {
136+ t . assert ||= require ( 'node:assert' )
137+
138+ spawnMock . mock . mockImplementationOnce ( ( ) => {
139+ return { status : 0 , stdout : '{}' }
140+ } )
141+
142+ const retObj = simctl . list ( { devicetypes : true } )
143+ t . assert . deepEqual ( spawnMock . mock . calls [ 0 ] . arguments [ 1 ] , [ 'simctl' , 'list' , 'devicetypes' , '--json' ] )
144+ t . assert . deepEqual ( retObj . json , { } )
145+ } )
146+
147+ await ctx . test ( 'with runtimes arguments' , ( t ) => {
148+ t . assert ||= require ( 'node:assert' )
149+
150+ spawnMock . mock . mockImplementationOnce ( ( ) => {
151+ return { status : 0 , stdout : '{}' }
152+ } )
153+
154+ const retObj = simctl . list ( { runtimes : true } )
155+ t . assert . deepEqual ( spawnMock . mock . calls [ 0 ] . arguments [ 1 ] , [ 'simctl' , 'list' , 'runtimes' , '--json' ] )
156+ t . assert . deepEqual ( retObj . json , { } )
157+ } )
158+
159+ await ctx . test ( 'with pairs arguments' , ( t ) => {
160+ t . assert ||= require ( 'node:assert' )
161+
162+ spawnMock . mock . mockImplementationOnce ( ( ) => {
163+ return { status : 0 , stdout : '{}' }
164+ } )
165+
166+ const retObj = simctl . list ( { pairs : true } )
167+ t . assert . deepEqual ( spawnMock . mock . calls [ 0 ] . arguments [ 1 ] , [ 'simctl' , 'list' , 'pairs' , '--json' ] )
168+ t . assert . deepEqual ( retObj . json , { } )
169+ } )
170+
171+ await ctx . test ( 'with parsing error' , ( t ) => {
172+ t . assert ||= require ( 'node:assert' )
173+
174+ spawnMock . mock . mockImplementationOnce ( ( ) => {
175+ return { status : 0 , stdout : 'This is not valid JSON' }
176+ } )
177+
178+ const retObj = simctl . list ( )
179+ t . assert . match ( console . error . mock . calls [ 0 ] . arguments [ 0 ] , / S y n t a x E r r o r : U n e x p e c t e d t o k e n / )
180+ t . assert . equal ( retObj . json , undefined )
181+ } )
182+ } )
0 commit comments