@@ -161,13 +161,20 @@ describe('GithubRepo', () => {
161
161
describe ( 'uploadReleaseAsset' , ( ) => {
162
162
let octoRequest : SinonStub ;
163
163
let getReleaseByTag : SinonStub ;
164
+ let deleteReleaseAsset : SinonStub ;
165
+
164
166
beforeEach ( ( ) => {
165
167
octoRequest = sinon . stub ( ) ;
166
168
octoRequest . resolves ( ) ;
167
169
getReleaseByTag = sinon . stub ( ) ;
168
170
getReleaseByTag . rejects ( ) ;
171
+ deleteReleaseAsset = sinon . stub ( ) ;
172
+ deleteReleaseAsset . rejects ( ) ;
169
173
githubRepo = getTestGithubRepo ( {
170
- request : octoRequest
174
+ request : octoRequest ,
175
+ repos : {
176
+ deleteReleaseAsset
177
+ }
171
178
} ) ;
172
179
githubRepo . getReleaseByTag = getReleaseByTag ;
173
180
} ) ;
@@ -186,6 +193,7 @@ describe('GithubRepo', () => {
186
193
path : __filename ,
187
194
contentType : 'xyz'
188
195
} ) ;
196
+ expect ( deleteReleaseAsset ) . to . not . have . been . called ;
189
197
expect ( octoRequest ) . to . have . been . calledWith ( {
190
198
method : 'POST' ,
191
199
url : 'url' ,
@@ -197,7 +205,7 @@ describe('GithubRepo', () => {
197
205
} ) ;
198
206
} ) ;
199
207
200
- it ( 'updates an existing asset' , async ( ) => {
208
+ it ( 'updates an existing asset by removing the old one first ' , async ( ) => {
201
209
const release = {
202
210
name : 'release' ,
203
211
tag : 'v0.8.0' ,
@@ -213,14 +221,20 @@ describe('GithubRepo', () => {
213
221
}
214
222
]
215
223
} ) ;
224
+ deleteReleaseAsset . resolves ( ) ;
216
225
217
226
await githubRepo . uploadReleaseAsset ( release , {
218
227
path : __filename ,
219
228
contentType : 'xyz'
220
229
} ) ;
230
+ expect ( deleteReleaseAsset ) . to . have . been . calledWith ( {
231
+ owner : 'mongodb-js' ,
232
+ repo : 'mongosh' ,
233
+ asset_id : 1
234
+ } ) ;
221
235
expect ( octoRequest ) . to . have . been . calledWith ( {
222
- method : 'PATCH ' ,
223
- url : 'assetUrl ' ,
236
+ method : 'POST ' ,
237
+ url : 'url ' ,
224
238
headers : {
225
239
'content-type' : 'xyz'
226
240
} ,
0 commit comments