@@ -150,6 +150,41 @@ describe('Replicate client', () => {
150150 // Add more tests for error handling, edge cases, etc.
151151 } ) ;
152152
153+ describe ( 'predictions.cancel' , ( ) => {
154+ test ( 'Calls the correct API route with the correct payload' , async ( ) => {
155+ nock ( BASE_URL )
156+ . post ( '/predictions/ufawqhfynnddngldkgtslldrkq/cancel' )
157+ . reply ( 200 , {
158+ id : 'ufawqhfynnddngldkgtslldrkq' ,
159+ version :
160+ '5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa' ,
161+ urls : {
162+ get : 'https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq' ,
163+ cancel :
164+ 'https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel' ,
165+ } ,
166+ created_at : '2022-04-26T22:13:06.224088Z' ,
167+ started_at : '2022-04-26T22:13:06.224088Z' ,
168+ completed_at : '2022-04-26T22:14:06.224088Z' ,
169+ status : 'canceled' ,
170+ input : {
171+ text : 'Alice' ,
172+ } ,
173+ output : null ,
174+ error : null ,
175+ logs : null ,
176+ metrics : { } ,
177+ } ) ;
178+
179+ const prediction = await client . predictions . cancel (
180+ 'ufawqhfynnddngldkgtslldrkq'
181+ ) ;
182+ expect ( prediction . status ) . toBe ( 'canceled' ) ;
183+ } ) ;
184+
185+ // Add more tests for error handling, edge cases, etc.
186+ } ) ;
187+
153188 describe ( 'predictions.list' , ( ) => {
154189 test ( 'Calls the correct API route with the correct payload' , async ( ) => {
155190 nock ( BASE_URL )
0 commit comments