@@ -599,6 +599,50 @@ describe("Clockodo (instance)", () => {
599599 } ) ;
600600 } ) ;
601601
602+ describe ( "getTeam()" , ( ) => {
603+ it ( "correctly builds getTeam() request" , async ( ) => {
604+ const nockScope = nock ( CLOCKODO_API_BASE_URL )
605+ . get ( "/v3/teams/1" )
606+ . reply ( 200 , { } ) ;
607+
608+ await expect ( clockodo . getTeam ( { id : 1 } ) ) . resolves . not . toBeInstanceOf (
609+ Error ,
610+ ) ;
611+
612+ nockScope . done ( ) ;
613+ } ) ;
614+ } ) ;
615+
616+ describe ( "getTeamsPage()" , ( ) => {
617+ it ( "correctly builds getTeamsPage() request" , async ( ) => {
618+ const nockScope = nock ( CLOCKODO_API_BASE_URL )
619+ . get ( "/v3/teams" )
620+ . reply ( 200 , { } ) ;
621+
622+ await expect ( clockodo . getTeamsPage ( ) ) . resolves . not . toBeInstanceOf (
623+ Error ,
624+ ) ;
625+
626+ nockScope . done ( ) ;
627+ } ) ;
628+ } ) ;
629+
630+ describe ( "getTeams()" , ( ) => {
631+ it ( "requests all team pages" , async ( ) => {
632+ const nockScope = setupPaginatedApiMock ( {
633+ baseUrl : "/v3/teams?" ,
634+ countPages : 3 ,
635+ createPageResponse : ( page ) => ( { data : [ page ] } ) ,
636+ } ) ;
637+
638+ const { data } = await clockodo . getTeams ( ) ;
639+
640+ expect ( data ) . toMatchObject ( [ 1 , 2 , 3 ] ) ;
641+
642+ nockScope . done ( ) ;
643+ } ) ;
644+ } ) ;
645+
602646 describe ( "getSingleTargetHourSet" , ( ) => {
603647 it ( "correctly builds getSingleTargetHourSet() request" , async ( ) => {
604648 const nockScope = nock ( CLOCKODO_API_BASE_URL )
@@ -641,13 +685,31 @@ describe("Clockodo (instance)", () => {
641685 } ) ;
642686 } ) ;
643687
644- describe ( "getUsers ()" , ( ) => {
645- it ( "correctly builds getUsers () request" , async ( ) => {
688+ describe ( "getUsersPage ()" , ( ) => {
689+ it ( "correctly builds getUsersPage () request" , async ( ) => {
646690 const nockScope = nock ( CLOCKODO_API_BASE_URL )
647691 . get ( "/v3/users" )
648692 . reply ( 200 , { } ) ;
649693
650- await expect ( clockodo . getUsers ( ) ) . resolves . not . toBeInstanceOf ( Error ) ;
694+ await expect ( clockodo . getUsersPage ( ) ) . resolves . not . toBeInstanceOf (
695+ Error ,
696+ ) ;
697+
698+ nockScope . done ( ) ;
699+ } ) ;
700+ } ) ;
701+
702+ describe ( "getUsers()" , ( ) => {
703+ it ( "requests all user pages" , async ( ) => {
704+ const nockScope = setupPaginatedApiMock ( {
705+ baseUrl : "/v3/users?" ,
706+ countPages : 3 ,
707+ createPageResponse : ( page ) => ( { data : [ page ] } ) ,
708+ } ) ;
709+
710+ const { data } = await clockodo . getUsers ( ) ;
711+
712+ expect ( data ) . toMatchObject ( [ 1 , 2 , 3 ] ) ;
651713
652714 nockScope . done ( ) ;
653715 } ) ;
0 commit comments