@@ -38,18 +38,28 @@ describe('PackagePublisher', function () {
3838 MONGOSH_RELEASE_PACKAGES . includes ( p . name )
3939 ) ;
4040
41- function setupTestPublisher ( config : PackagePublisherConfig ) {
41+ function setupTestPublisher (
42+ config : PackagePublisherConfig ,
43+ {
44+ existsTagStub = sinon . stub ( ) ,
45+ } : {
46+ existsTagStub ?: SinonStub | null ;
47+ } = { }
48+ ) {
4249 spawnSync = sinon . stub ( ) ;
50+ spawnSync . returns ( undefined ) ;
4351
4452 testPublisher = new PackagePublisher ( config , { spawnSync } ) ;
4553
46- spawnSync . returns ( undefined ) ;
47-
4854 listNpmPackages = sinon . stub ( testPublisher , 'listNpmPackages' ) ;
4955 listNpmPackages . returns ( allReleasablePackages ) ;
5056
51- existsTag = sinon . stub ( testPublisher , 'existsTag' ) ;
52- existsTag . returns ( false ) ;
57+ if ( existsTagStub ) {
58+ console . log ( 'setting up...' ) ;
59+ sinon . replace ( testPublisher , 'existsTag' , existsTagStub ) ;
60+ existsTag = existsTagStub ;
61+ existsTagStub . returns ( false ) ;
62+ }
5363 }
5464
5565 describe ( 'publish()' , function ( ) {
@@ -245,11 +255,17 @@ describe('PackagePublisher', function () {
245255 } ) ;
246256
247257 describe ( 'existsTag()' , function ( ) {
258+ beforeEach ( function ( ) {
259+ setupTestPublisher ( { } , { existsTagStub : null } ) ;
260+ } ) ;
261+
248262 it ( 'returns true with existing tags' , function ( ) {
263+ spawnSync . returns ( { status : 0 } ) ;
249264 expect ( testPublisher . existsTag ( 'v1.0.0' ) ) . equals ( true ) ;
250265 } ) ;
251266
252267 it ( 'return false with tags that do not exist' , function ( ) {
268+ spawnSync . returns ( { status : 1 } ) ;
253269 expect ( testPublisher . existsTag ( 'this-tag-will-never-exist-12345' ) ) . equals (
254270 false
255271 ) ;
0 commit comments