@@ -440,94 +440,6 @@ describe('DrsClient', () => {
440440 } ) ;
441441 } ) ;
442442
443- describe ( 'pollJobStatus' , ( ) => {
444- it ( 'resolves immediately when job is already completed' , async ( ) => {
445- nock ( API_BASE_URL )
446- . get ( '/jobs/job-123' )
447- . query ( { include_result_url : 'true' } )
448- . reply ( 200 , jobStatusCompletedResponse ) ;
449-
450- const result = await client . pollJobStatus ( 'job-123' , { pollIntervalMs : 10 , maxTimeoutMs : 100 } ) ;
451- expect ( result ) . to . deep . equal ( jobStatusCompletedResponse ) ;
452- } ) ;
453-
454- it ( 'resolves when job completes after multiple polls' , async ( ) => {
455- nock ( API_BASE_URL )
456- . get ( '/jobs/job-123' )
457- . query ( { include_result_url : 'true' } )
458- . reply ( 200 , jobStatusQueuedResponse ) ;
459-
460- nock ( API_BASE_URL )
461- . get ( '/jobs/job-123' )
462- . query ( { include_result_url : 'true' } )
463- . reply ( 200 , jobStatusRunningResponse ) ;
464-
465- nock ( API_BASE_URL )
466- . get ( '/jobs/job-123' )
467- . query ( { include_result_url : 'true' } )
468- . reply ( 200 , jobStatusCompletedResponse ) ;
469-
470- const result = await client . pollJobStatus ( 'job-123' , { pollIntervalMs : 10 , maxTimeoutMs : 5000 } ) ;
471- expect ( result ) . to . deep . equal ( jobStatusCompletedResponse ) ;
472- expect ( log . info . callCount ) . to . equal ( 2 ) ;
473- } ) ;
474-
475- it ( 'resolves when job fails' , async ( ) => {
476- nock ( API_BASE_URL )
477- . get ( '/jobs/job-123' )
478- . query ( { include_result_url : 'true' } )
479- . reply ( 200 , jobStatusRunningResponse ) ;
480-
481- nock ( API_BASE_URL )
482- . get ( '/jobs/job-123' )
483- . query ( { include_result_url : 'true' } )
484- . reply ( 200 , jobStatusFailedResponse ) ;
485-
486- const result = await client . pollJobStatus ( 'job-123' , { pollIntervalMs : 10 , maxTimeoutMs : 5000 } ) ;
487- expect ( result . status ) . to . equal ( 'FAILED' ) ;
488- } ) ;
489-
490- it ( 'throws error on timeout' , async ( ) => {
491- nock ( API_BASE_URL )
492- . get ( '/jobs/job-123' )
493- . query ( { include_result_url : 'true' } )
494- . times ( 10 )
495- . reply ( 200 , jobStatusRunningResponse ) ;
496-
497- await expect ( client . pollJobStatus ( 'job-123' , { pollIntervalMs : 10 , maxTimeoutMs : 25 } ) )
498- . to . be . rejectedWith ( 'Polling for job job-123 timed out after 25ms. Last status: RUNNING' ) ;
499- } ) ;
500-
501- it ( 'propagates API error during polling' , async ( ) => {
502- nock ( API_BASE_URL )
503- . get ( '/jobs/job-123' )
504- . query ( { include_result_url : 'true' } )
505- . reply ( 200 , jobStatusRunningResponse ) ;
506-
507- nock ( API_BASE_URL )
508- . get ( '/jobs/job-123' )
509- . query ( { include_result_url : 'true' } )
510- . reply ( 500 , { message : 'Internal Server Error' } ) ;
511-
512- await expect ( client . pollJobStatus ( 'job-123' , { pollIntervalMs : 10 , maxTimeoutMs : 5000 } ) )
513- . to . be . rejectedWith ( 'DRS API request to /jobs/job-123?include_result_url=true failed with status: 500 - Internal Server Error' ) ;
514- } ) ;
515-
516- it ( 'throws error when job ID is missing' , async ( ) => {
517- await expect ( client . pollJobStatus ( '' ) ) . to . be . rejectedWith ( 'Job ID is required' ) ;
518- } ) ;
519-
520- it ( 'uses default poll options when none provided' , async ( ) => {
521- nock ( API_BASE_URL )
522- . get ( '/jobs/job-123' )
523- . query ( { include_result_url : 'true' } )
524- . reply ( 200 , jobStatusCompletedResponse ) ;
525-
526- const result = await client . pollJobStatus ( 'job-123' ) ;
527- expect ( result ) . to . deep . equal ( jobStatusCompletedResponse ) ;
528- } ) ;
529- } ) ;
530-
531443 describe ( 'lookupUrls' , ( ) => {
532444 const lookupUrls = [
533445 'https://www.reddit.com/r/technology/comments/abc123/post_title/' ,
0 commit comments