@@ -162,6 +162,108 @@ test('run version and make sure commit hooks are disabled by config', async ():
162162 } ) ;
163163} ) ;
164164
165+ test ( 'run version with --no-git-tag-version and make sure git tags are disabled' , async ( ) : Promise < void > => {
166+ const fixture = 'no-args' ;
167+ await fs . mkdirp ( path . join ( fixturesLoc , fixture , '.git' ) ) ;
168+
169+ return runRun ( [ ] , { newVersion, gitTagVersion : false } , fixture , async ( config ) : ?Promise < void > => {
170+ const pkg = await fs . readJson ( path . join ( config . cwd , 'package.json' ) ) ;
171+ expect ( pkg . version ) . toBe ( newVersion ) ;
172+
173+ expect ( spawn . mock . calls . length ) . toBe ( 0 ) ;
174+ } ) ;
175+ } ) ;
176+
177+ test ( 'run version and make sure git tags are disabled by config' , async ( ) : Promise < void > => {
178+ const fixture = 'no-args-no-git-tags' ;
179+ await fs . mkdirp ( path . join ( fixturesLoc , fixture , '.git' ) ) ;
180+
181+ return runRun ( [ ] , { newVersion, gitTagVersion} , fixture , async ( config ) : ?Promise < void > => {
182+ const pkg = await fs . readJson ( path . join ( config . cwd , 'package.json' ) ) ;
183+ expect ( pkg . version ) . toBe ( newVersion ) ;
184+
185+ expect ( spawn . mock . calls . length ) . toBe ( 0 ) ;
186+ } ) ;
187+ } ) ;
188+
189+ test ( 'run version with --no-git-tag-version, make sure all lifecycle steps runs' , async ( ) : Promise < void > => {
190+ const fixture = 'no-args' ;
191+ await fs . mkdirp ( path . join ( fixturesLoc , fixture , '.git' ) ) ;
192+
193+ return runRun ( [ ] , { newVersion, gitTagVersion : false } , fixture , async ( config ) : ?Promise < void > => {
194+ expect ( spawn . mock . calls . length ) . toBe ( 0 ) ;
195+
196+ const pkg = await fs . readJson ( path . join ( config . cwd , 'package.json' ) ) ;
197+
198+ const preversionLifecycle = {
199+ stage : 'preversion' ,
200+ config,
201+ cmd : pkg . scripts . preversion ,
202+ cwd : config . cwd ,
203+ isInteractive : true ,
204+ } ;
205+ const versionLifecycle = {
206+ stage : 'version' ,
207+ config,
208+ cmd : pkg . scripts . version ,
209+ cwd : config . cwd ,
210+ isInteractive : true ,
211+ } ;
212+ const postversionLifecycle = {
213+ stage : 'postversion' ,
214+ config,
215+ cmd : pkg . scripts . postversion ,
216+ cwd : config . cwd ,
217+ isInteractive : true ,
218+ } ;
219+
220+ expect ( execCommand . mock . calls . length ) . toBe ( 3 ) ;
221+
222+ expect ( execCommand . mock . calls [ 0 ] ) . toEqual ( [ preversionLifecycle ] ) ;
223+ expect ( execCommand . mock . calls [ 1 ] ) . toEqual ( [ versionLifecycle ] ) ;
224+ expect ( execCommand . mock . calls [ 2 ] ) . toEqual ( [ postversionLifecycle ] ) ;
225+ } ) ;
226+ } ) ;
227+
228+ test ( 'run version with git tags disabled in config, make sure all lifecycle steps runs' , async ( ) : Promise < void > => {
229+ const fixture = 'no-args-no-git-tags' ;
230+ await fs . mkdirp ( path . join ( fixturesLoc , fixture , '.git' ) ) ;
231+
232+ return runRun ( [ ] , { newVersion, gitTagVersion} , fixture , async ( config ) : ?Promise < void > => {
233+ expect ( spawn . mock . calls . length ) . toBe ( 0 ) ;
234+
235+ const pkg = await fs . readJson ( path . join ( config . cwd , 'package.json' ) ) ;
236+
237+ const preversionLifecycle = {
238+ stage : 'preversion' ,
239+ config,
240+ cmd : pkg . scripts . preversion ,
241+ cwd : config . cwd ,
242+ isInteractive : true ,
243+ } ;
244+ const versionLifecycle = {
245+ stage : 'version' ,
246+ config,
247+ cmd : pkg . scripts . version ,
248+ cwd : config . cwd ,
249+ isInteractive : true ,
250+ } ;
251+ const postversionLifecycle = {
252+ stage : 'postversion' ,
253+ config,
254+ cmd : pkg . scripts . postversion ,
255+ cwd : config . cwd ,
256+ isInteractive : true ,
257+ } ;
258+
259+ expect ( execCommand . mock . calls . length ) . toBe ( 3 ) ;
260+
261+ expect ( execCommand . mock . calls [ 0 ] ) . toEqual ( [ preversionLifecycle ] ) ;
262+ expect ( execCommand . mock . calls [ 1 ] ) . toEqual ( [ versionLifecycle ] ) ;
263+ expect ( execCommand . mock . calls [ 2 ] ) . toEqual ( [ postversionLifecycle ] ) ;
264+ } ) ;
265+ } ) ;
266+
165267test ( 'run version with --major flag and make sure major version is incremented' , ( ) : Promise < void > => {
166268 return runRun ( [ ] , { gitTagVersion, major : true } , 'no-args' , async ( config ) : ?Promise < void > => {
167269 const pkg = await fs . readJson ( path . join ( config . cwd , 'package.json' ) ) ;
0 commit comments