@@ -287,6 +287,51 @@ describe('client', async () => {
287
287
expect ( projects [ 0 ] . id , 'should have project id' ) . toBe ( 'foo' )
288
288
} )
289
289
290
+ test ( 'can request list of projects with members' , async ( ) => {
291
+ nock ( `https://${ apiHost } ` )
292
+ . get ( '/v1/projects' )
293
+ . times ( 2 )
294
+ . reply ( 200 , [ { id : 'foo' } , { id : 'bar' } ] )
295
+
296
+ const client = createClient ( { useProjectHostname : false , apiHost : `https://${ apiHost } ` } )
297
+ let projects = await client . projects . list ( { includeMembers : true } )
298
+ expect ( projects . length , 'should have two projects' ) . toBe ( 2 )
299
+ expect ( projects [ 0 ] . id , 'should have project id' ) . toBe ( 'foo' )
300
+
301
+ projects = await client . projects . list ( { includeMembers : undefined } )
302
+ expect ( projects . length , 'should have two projects' ) . toBe ( 2 )
303
+ expect ( projects [ 0 ] . id , 'should have project id' ) . toBe ( 'foo' )
304
+ } )
305
+
306
+ test ( 'can request list of projects without members' , async ( ) => {
307
+ nock ( `https://${ apiHost } ` )
308
+ . get ( '/v1/projects?includeMembers=false' )
309
+ . reply ( 200 , [ { id : 'foo' } , { id : 'bar' } ] )
310
+
311
+ const client = createClient ( { useProjectHostname : false , apiHost : `https://${ apiHost } ` } )
312
+ const projects = await client . projects . list ( { includeMembers : false } )
313
+ expect ( projects . length , 'should have two projects' ) . toBe ( 2 )
314
+ expect ( projects [ 0 ] . id , 'should have project id' ) . toBe ( 'foo' )
315
+ expect ( projects [ 0 ] ) . not . toHaveProperty ( 'members' )
316
+
317
+ // @ts -expect-error - `members` should not be part of type when using `includeMembers: false`
318
+ expect ( projects [ 0 ] . members , 'should not have "members" prop' ) . toBeUndefined ( )
319
+ } )
320
+
321
+ test ( 'can request list of projects, ignoring non-false `includeMembers` option' , async ( ) => {
322
+ nock ( `https://${ apiHost } ` )
323
+ . get ( '/v1/projects' )
324
+ . reply ( 200 , [ { id : 'foo' } , { id : 'bar' } ] )
325
+
326
+ const client = createClient ( { useProjectHostname : false , apiHost : `https://${ apiHost } ` } )
327
+
328
+ // @ts -expect-error - `includeMembers` should be a boolean if specified
329
+ const projects = await client . projects . list ( { includeMembers : 'nope' } )
330
+
331
+ expect ( projects . length , 'should have two projects' ) . toBe ( 2 )
332
+ expect ( projects [ 0 ] . id , 'should have project id' ) . toBe ( 'foo' )
333
+ } )
334
+
290
335
test ( 'can request list of projects (custom api version)' , async ( ) => {
291
336
nock ( `https://${ apiHost } ` )
292
337
. get ( '/v2019-01-29/projects' )
0 commit comments