@@ -151,6 +151,18 @@ describe('Replicate client', () => {
151151 } ) ;
152152 expect ( prediction . id ) . toBe ( 'ufawqhfynnddngldkgtslldrkq' ) ;
153153 } ) ;
154+
155+ test ( 'Throws an error if webhook URL is invalid' , async ( ) => {
156+ await expect ( async ( ) => {
157+ await client . predictions . create ( {
158+ version : '5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa' ,
159+ input : {
160+ text : 'Alice' ,
161+ } ,
162+ webhook : 'invalid-url' ,
163+ } ) ;
164+ } ) . rejects . toThrow ( 'Invalid webhook URL' ) ;
165+ } ) ;
154166 // Add more tests for error handling, edge cases, etc.
155167 } ) ;
156168
@@ -321,6 +333,23 @@ describe('Replicate client', () => {
321333 expect ( training . id ) . toBe ( 'zz4ibbonubfz7carwiefibzgga' ) ;
322334 } ) ;
323335
336+ test ( 'Throws an error if webhook is not a valid URL' , async ( ) => {
337+ await expect (
338+ client . trainings . create (
339+ 'owner' ,
340+ 'model' ,
341+ '632231d0d49d34d5c4633bd838aee3d81d936e59a886fbf28524702003b4c532' ,
342+ {
343+ destination : 'new_owner/new_model' ,
344+ input : {
345+ text : '...' ,
346+ } ,
347+ webhook : 'invalid-url' ,
348+ }
349+ )
350+ ) . rejects . toThrow ( 'Invalid webhook URL' ) ;
351+ } ) ;
352+
324353 // Add more tests for error handling, edge cases, etc.
325354 } ) ;
326355
@@ -499,6 +528,18 @@ describe('Replicate client', () => {
499528 // @ts -expect-error
500529 await expect ( client . run ( ':abc123' , options ) ) . rejects . toThrow ( ) ;
501530 } ) ;
531+
532+ test ( 'Throws an error if webhook URL is invalid' , async ( ) => {
533+ await expect ( async ( ) => {
534+ await client . run (
535+ 'owner/model:5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa' , {
536+ input : {
537+ text : 'Alice' ,
538+ } ,
539+ webhook : 'invalid-url' ,
540+ } ) ;
541+ } ) . rejects . toThrow ( 'Invalid webhook URL' ) ;
542+ } ) ;
502543 } ) ;
503544
504545 // Continue with tests for other methods
0 commit comments