@@ -114,6 +114,50 @@ describe("Replicate client", () => {
114
114
const collections = await client . collections . list ( ) ;
115
115
expect ( collections . results . length ) . toBe ( 2 ) ;
116
116
} ) ;
117
+
118
+ describe ( "predictions.create" , ( ) => {
119
+ test ( "Handles array input correctly" , async ( ) => {
120
+ const inputArray = [ "Alice" , "Bob" , "Charlie" ] ;
121
+
122
+ nock ( BASE_URL )
123
+ . post ( "/predictions" , {
124
+ version :
125
+ "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa" ,
126
+ input : {
127
+ text : inputArray ,
128
+ } ,
129
+ } )
130
+ . reply ( 200 , {
131
+ id : "ufawqhfynnddngldkgtslldrkq" ,
132
+ model : "replicate/hello-world" ,
133
+ version :
134
+ "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa" ,
135
+ urls : {
136
+ get : "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq" ,
137
+ cancel :
138
+ "https://api.replicate.com/v1/predictions/ufawqhfynnddngldkgtslldrkq/cancel" ,
139
+ } ,
140
+ created_at : "2022-04-26T22:13:06.224088Z" ,
141
+ started_at : null ,
142
+ completed_at : null ,
143
+ status : "starting" ,
144
+ input : {
145
+ text : inputArray ,
146
+ } ,
147
+ } ) ;
148
+
149
+ const response = await client . predictions . create ( {
150
+ version :
151
+ "5c7d5dc6dd8bf75c1acaa8565735e7986bc5b66206b55cca93cb72c9bf15ccaa" ,
152
+ input : {
153
+ text : inputArray ,
154
+ } ,
155
+ } ) ;
156
+
157
+ expect ( response . input ) . toEqual ( { text : inputArray } ) ;
158
+ expect ( response . status ) . toBe ( "starting" ) ;
159
+ } ) ;
160
+ } ) ;
117
161
// Add more tests for error handling, edge cases, etc.
118
162
} ) ;
119
163
0 commit comments