@@ -594,4 +594,107 @@ describe("ZendeskService", () => {
594594 expect ( result ) . toEqual ( zisIntegration ) ;
595595 } ) ;
596596 } ) ;
597+
598+ describe ( "jobSpecs" , ( ) => {
599+ const jobSpec = {
600+ description : "Test Job" ,
601+ event_source : "source" ,
602+ event_type : "type" ,
603+ flow_name : "flow" ,
604+ installed : true ,
605+ integration : "integration" ,
606+ name : "jobName" ,
607+ uuid : "uuid"
608+ } ;
609+
610+ it ( "should fetchs jobs and call Zendesk API multiple times if has more is true" , async ( ) => {
611+ requestMock
612+ . mockResolvedValueOnce ( {
613+ job_specs : [ jobSpec ] ,
614+ meta : {
615+ has_more : true ,
616+ after : "1"
617+ }
618+ } )
619+ . mockResolvedValueOnce ( {
620+ job_specs : [ jobSpec ] ,
621+ meta : {
622+ has_more : false
623+ }
624+ } ) ;
625+
626+ const data = await service . fetchZisJobSpecs ( "integrationName" ) ;
627+
628+ expect ( requestMock ) . toHaveBeenNthCalledWith ( 1 , {
629+ url : "/api/services/zis/registry/integrationName/job_specs" ,
630+ type : "GET" ,
631+ data : {
632+ page : {
633+ size : "100"
634+ }
635+ }
636+ } ) ;
637+ expect ( requestMock ) . toHaveBeenNthCalledWith ( 2 , {
638+ url : "/api/services/zis/registry/integrationName/job_specs" ,
639+ type : "GET" ,
640+ data : {
641+ page : {
642+ after : "1" ,
643+ size : "100"
644+ }
645+ }
646+ } ) ;
647+ expect ( requestMock ) . toHaveBeenCalledTimes ( 2 ) ;
648+ expect ( data ) . toHaveLength ( 2 ) ;
649+ } ) ;
650+
651+ it ( "should fetchs jobs with correct data" , async ( ) => {
652+ requestMock . mockResolvedValueOnce ( {
653+ job_specs : [ jobSpec ] ,
654+ meta : {
655+ has_more : false
656+ }
657+ } ) ;
658+
659+ const data = await service . fetchZisJobSpecs ( "integrationName" , {
660+ page : {
661+ size : "5"
662+ }
663+ } ) ;
664+
665+ expect ( requestMock ) . toHaveBeenNthCalledWith ( 1 , {
666+ url : "/api/services/zis/registry/integrationName/job_specs" ,
667+ type : "GET" ,
668+ data : {
669+ page : {
670+ size : "5"
671+ }
672+ }
673+ } ) ;
674+ expect ( requestMock ) . toHaveBeenCalledTimes ( 1 ) ;
675+ expect ( data ) . toHaveLength ( 1 ) ;
676+ } ) ;
677+
678+ it ( "should create a job spec with correct data" , async ( ) => {
679+ await service . createZisJobSpec ( "job_name_test" ) ;
680+
681+ expect ( requestMock ) . toHaveBeenNthCalledWith ( 1 , {
682+ url : "/api/services/zis/registry/job_specs/install?job_spec_name=job_name_test" ,
683+ type : "POST" ,
684+ contentType : "application/json"
685+ } ) ;
686+ expect ( requestMock ) . toHaveBeenCalledTimes ( 1 ) ;
687+ } ) ;
688+
689+ it ( "should delete a job spec with correct data" , async ( ) => {
690+ await service . deleteZisJobSpec ( "job_name_test" ) ;
691+
692+ expect ( requestMock ) . toHaveBeenNthCalledWith ( 1 , {
693+ url : "/api/services/zis/registry/job_specs/install?job_spec_name=job_name_test" ,
694+ type : "DELETE" ,
695+ contentType : "application/json"
696+ } ) ;
697+ expect ( requestMock ) . toHaveBeenCalledTimes ( 1 ) ;
698+ } ) ;
699+ } ) ;
597700} ) ;
0 commit comments