@@ -276,4 +276,46 @@ describe("createPrediction()", () => {
276276 input : { text : "test text" } ,
277277 } ) ;
278278 } ) ;
279+
280+ it ( "supports webhook string" , async ( ) => {
281+ jest . spyOn ( client , "request" ) . mockResolvedValue ( {
282+ id : "testprediction" ,
283+ status : PredictionStatus . SUCCEEDED ,
284+ } ) ;
285+
286+ await model . createPrediction (
287+ { text : "test text" } ,
288+ { webhook : "http://test.host/webhook" }
289+ ) ;
290+
291+ expect ( client . request ) . toHaveBeenCalledWith ( "POST /v1/predictions" , {
292+ version : "testversion" ,
293+ input : { text : "test text" } ,
294+ webhook : "http://test.host/webhook" ,
295+ } ) ;
296+ } ) ;
297+
298+ it ( "supports webhook object" , async ( ) => {
299+ jest . spyOn ( client , "request" ) . mockResolvedValue ( {
300+ id : "testprediction" ,
301+ status : PredictionStatus . SUCCEEDED ,
302+ } ) ;
303+
304+ await model . createPrediction (
305+ { text : "test text" } ,
306+ {
307+ webhook : {
308+ url : "http://test.host/webhook" ,
309+ events : [ "output" , "completed" ] ,
310+ } ,
311+ }
312+ ) ;
313+
314+ expect ( client . request ) . toHaveBeenCalledWith ( "POST /v1/predictions" , {
315+ version : "testversion" ,
316+ input : { text : "test text" } ,
317+ webhook : "http://test.host/webhook" ,
318+ webhook_events_filter : [ "output" , "completed" ] ,
319+ } ) ;
320+ } ) ;
279321} ) ;
0 commit comments