@@ -161,13 +161,20 @@ describe('GithubRepo', () => {
161161 describe ( 'uploadReleaseAsset' , ( ) => {
162162 let octoRequest : SinonStub ;
163163 let getReleaseByTag : SinonStub ;
164+ let deleteReleaseAsset : SinonStub ;
165+
164166 beforeEach ( ( ) => {
165167 octoRequest = sinon . stub ( ) ;
166168 octoRequest . resolves ( ) ;
167169 getReleaseByTag = sinon . stub ( ) ;
168170 getReleaseByTag . rejects ( ) ;
171+ deleteReleaseAsset = sinon . stub ( ) ;
172+ deleteReleaseAsset . rejects ( ) ;
169173 githubRepo = getTestGithubRepo ( {
170- request : octoRequest
174+ request : octoRequest ,
175+ repos : {
176+ deleteReleaseAsset
177+ }
171178 } ) ;
172179 githubRepo . getReleaseByTag = getReleaseByTag ;
173180 } ) ;
@@ -186,6 +193,7 @@ describe('GithubRepo', () => {
186193 path : __filename ,
187194 contentType : 'xyz'
188195 } ) ;
196+ expect ( deleteReleaseAsset ) . to . not . have . been . called ;
189197 expect ( octoRequest ) . to . have . been . calledWith ( {
190198 method : 'POST' ,
191199 url : 'url' ,
@@ -197,7 +205,7 @@ describe('GithubRepo', () => {
197205 } ) ;
198206 } ) ;
199207
200- it ( 'updates an existing asset' , async ( ) => {
208+ it ( 'updates an existing asset by removing the old one first ' , async ( ) => {
201209 const release = {
202210 name : 'release' ,
203211 tag : 'v0.8.0' ,
@@ -213,14 +221,20 @@ describe('GithubRepo', () => {
213221 }
214222 ]
215223 } ) ;
224+ deleteReleaseAsset . resolves ( ) ;
216225
217226 await githubRepo . uploadReleaseAsset ( release , {
218227 path : __filename ,
219228 contentType : 'xyz'
220229 } ) ;
230+ expect ( deleteReleaseAsset ) . to . have . been . calledWith ( {
231+ owner : 'mongodb-js' ,
232+ repo : 'mongosh' ,
233+ asset_id : 1
234+ } ) ;
221235 expect ( octoRequest ) . to . have . been . calledWith ( {
222- method : 'PATCH ' ,
223- url : 'assetUrl ' ,
236+ method : 'POST ' ,
237+ url : 'url ' ,
224238 headers : {
225239 'content-type' : 'xyz'
226240 } ,
0 commit comments