11"use strict" ;
22
3- const { files } = require ( "../utils" ) ;
4- const { chaiExec , expect } = require ( "../utils/ chai" ) ;
3+ const { files, bump } = require ( "../utils" ) ;
4+ const { expect } = require ( "chai" ) ;
55const manifest = require ( "../../package.json" ) ;
66
77describe ( "bump" , ( ) => {
@@ -13,110 +13,110 @@ describe("bump", () => {
1313 // Run the CLI without any arguments.
1414 // It will prompt the user and wait forever, so add a timeout.
1515 this . timeout ( Math . max ( 10000 , this . timeout ( ) ) ) ;
16- let bump = chaiExec ( "" , { timeout : 6000 } ) ;
16+ let cli = bump ( "" , { timeout : 6000 } ) ;
1717
1818 // It should have prompted for input
19- expect ( bump . stdout ) . to . contain ( "The current version in package.json is 1.0.0\nHow would you like to bump it? (Use arrow keys)" ) ;
19+ expect ( cli . stdout ) . to . contain ( "The current version in package.json is 1.0.0\nHow would you like to bump it? (Use arrow keys)" ) ;
2020 } ) ;
2121
2222 it ( "should error if an invalid argument is used" , ( ) => {
23- let bump = chaiExec ( "--commit --help --fizzbuzz --quiet" ) ;
23+ let cli = bump ( "--commit --help --fizzbuzz --quiet" ) ;
2424
25- expect ( bump ) . to . have . exitCode ( 9 ) ;
26- expect ( bump ) . to . have . stdout ( "" ) ;
27- expect ( bump . stderr ) . to . match ( / ^ U n k n o w n o p t i o n : - - f i z z b u z z \n \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
28- expect ( bump . stderr ) . to . contain ( manifest . description ) ;
25+ expect ( cli ) . to . have . exitCode ( 9 ) ;
26+ expect ( cli ) . to . have . stdout ( "" ) ;
27+ expect ( cli . stderr ) . to . match ( / ^ U n k n o w n o p t i o n : - - f i z z b u z z \n \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
28+ expect ( cli . stderr ) . to . contain ( manifest . description ) ;
2929 } ) ;
3030
3131 it ( "should error if an invalid shorthand argument is used" , ( ) => {
32- let bump = chaiExec ( "-cqhzt" ) ;
32+ let cli = bump ( "-cqhzt" ) ;
3333
34- expect ( bump ) . to . have . exitCode ( 9 ) ;
35- expect ( bump ) . to . have . stdout ( "" ) ;
36- expect ( bump . stderr ) . to . match ( / ^ U n k n o w n o p t i o n : - z \n \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
37- expect ( bump . stderr ) . to . contain ( manifest . description ) ;
34+ expect ( cli ) . to . have . exitCode ( 9 ) ;
35+ expect ( cli ) . to . have . stdout ( "" ) ;
36+ expect ( cli . stderr ) . to . match ( / ^ U n k n o w n o p t i o n : - z \n \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
37+ expect ( cli . stderr ) . to . contain ( manifest . description ) ;
3838 } ) ;
3939
4040 it ( "should error if an argument is missing its value" , ( ) => {
41- let bump = chaiExec ( "--commit --help --preid --quiet" ) ;
41+ let cli = bump ( "--commit --help --preid --quiet" ) ;
4242
43- expect ( bump ) . to . have . exitCode ( 9 ) ;
44- expect ( bump ) . to . have . stdout ( "" ) ;
45- bump . stderr . should . match (
43+ expect ( cli ) . to . have . exitCode ( 9 ) ;
44+ expect ( cli ) . to . have . stdout ( "" ) ;
45+ expect ( cli . stderr ) . to . match (
4646 / ^ T h e - - p r e i d o p t i o n r e q u i r e s a v a l u e , s u c h a s " a l p h a " , " b e t a " , e t c \. \n \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n /
4747 ) ;
48- expect ( bump . stderr ) . to . contain ( manifest . description ) ;
48+ expect ( cli . stderr ) . to . contain ( manifest . description ) ;
4949 } ) ;
5050
5151 describe ( "bump --help" , ( ) => {
5252 it ( "should show usage text" , ( ) => {
53- let bump = chaiExec ( "--help" ) ;
53+ let cli = bump ( "--help" ) ;
5454
55- expect ( bump ) . to . have . exitCode ( 0 ) ;
56- expect ( bump ) . to . have . stderr ( "" ) ;
57- expect ( bump . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
58- expect ( bump . stdout ) . to . contain ( manifest . description ) ;
55+ expect ( cli ) . to . have . exitCode ( 0 ) ;
56+ expect ( cli ) . to . have . stderr ( "" ) ;
57+ expect ( cli . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
58+ expect ( cli . stdout ) . to . contain ( manifest . description ) ;
5959 } ) ;
6060
6161 it ( "should support -h shorthand" , ( ) => {
62- let bump = chaiExec ( "-h" ) ;
62+ let cli = bump ( "-h" ) ;
6363
64- expect ( bump ) . to . have . exitCode ( 0 ) ;
65- expect ( bump ) . to . have . stderr ( "" ) ;
66- expect ( bump . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
67- expect ( bump . stdout ) . to . contain ( manifest . description ) ;
64+ expect ( cli ) . to . have . exitCode ( 0 ) ;
65+ expect ( cli ) . to . have . stderr ( "" ) ;
66+ expect ( cli . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
67+ expect ( cli . stdout ) . to . contain ( manifest . description ) ;
6868 } ) ;
6969
7070 it ( "should ignore other arguments" , ( ) => {
71- let bump = chaiExec ( "--quiet --help --tag" ) ;
71+ let cli = bump ( "--quiet --help --tag" ) ;
7272
73- expect ( bump ) . to . have . exitCode ( 0 ) ;
74- expect ( bump ) . to . have . stderr ( "" ) ;
75- expect ( bump . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
76- expect ( bump . stdout ) . to . contain ( manifest . description ) ;
73+ expect ( cli ) . to . have . exitCode ( 0 ) ;
74+ expect ( cli ) . to . have . stderr ( "" ) ;
75+ expect ( cli . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
76+ expect ( cli . stdout ) . to . contain ( manifest . description ) ;
7777 } ) ;
7878
7979 it ( "should ignore other shorthand arguments" , ( ) => {
80- let bump = chaiExec ( "-cht" ) ;
80+ let cli = bump ( "-cht" ) ;
8181
82- expect ( bump ) . to . have . exitCode ( 0 ) ;
83- expect ( bump ) . to . have . stderr ( "" ) ;
84- expect ( bump . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
85- expect ( bump . stdout ) . to . contain ( manifest . description ) ;
82+ expect ( cli ) . to . have . exitCode ( 0 ) ;
83+ expect ( cli ) . to . have . stderr ( "" ) ;
84+ expect ( cli . stdout ) . to . match ( / ^ \n U s a g e : b u m p \[ r e l e a s e \] \[ o p t i o n s \] \[ f i l e s ...\] \n / ) ;
85+ expect ( cli . stdout ) . to . contain ( manifest . description ) ;
8686 } ) ;
8787 } ) ;
8888
8989 describe ( "bump --version" , ( ) => {
9090 it ( "should show the version number" , ( ) => {
91- let bump = chaiExec ( "--version" ) ;
91+ let cli = bump ( "--version" ) ;
9292
93- expect ( bump ) . to . have . exitCode ( 0 ) ;
94- expect ( bump ) . to . have . stderr ( "" ) ;
95- expect ( bump ) . to . have . stdout ( manifest . version + "\n" ) ;
93+ expect ( cli ) . to . have . exitCode ( 0 ) ;
94+ expect ( cli ) . to . have . stderr ( "" ) ;
95+ expect ( cli ) . to . have . stdout ( manifest . version + "\n" ) ;
9696 } ) ;
9797
9898 it ( "should support -v shorthand" , ( ) => {
99- let bump = chaiExec ( "-v" ) ;
99+ let cli = bump ( "-v" ) ;
100100
101- expect ( bump ) . to . have . exitCode ( 0 ) ;
102- expect ( bump ) . to . have . stderr ( "" ) ;
103- expect ( bump ) . to . have . stdout ( manifest . version + "\n" ) ;
101+ expect ( cli ) . to . have . exitCode ( 0 ) ;
102+ expect ( cli ) . to . have . stderr ( "" ) ;
103+ expect ( cli ) . to . have . stdout ( manifest . version + "\n" ) ;
104104 } ) ;
105105
106106 it ( "should ignore other arguments" , ( ) => {
107- let bump = chaiExec ( "--quiet --version --tag" ) ;
107+ let cli = bump ( "--quiet --version --tag" ) ;
108108
109- expect ( bump ) . to . have . exitCode ( 0 ) ;
110- expect ( bump ) . to . have . stderr ( "" ) ;
111- expect ( bump ) . to . have . stdout ( manifest . version + "\n" ) ;
109+ expect ( cli ) . to . have . exitCode ( 0 ) ;
110+ expect ( cli ) . to . have . stderr ( "" ) ;
111+ expect ( cli ) . to . have . stdout ( manifest . version + "\n" ) ;
112112 } ) ;
113113
114114 it ( "should ignore other shorthand arguments" , ( ) => {
115- let bump = chaiExec ( "-cvt" ) ;
115+ let cli = bump ( "-cvt" ) ;
116116
117- expect ( bump ) . to . have . exitCode ( 0 ) ;
118- expect ( bump ) . to . have . stderr ( "" ) ;
119- expect ( bump ) . to . have . stdout ( manifest . version + "\n" ) ;
117+ expect ( cli ) . to . have . exitCode ( 0 ) ;
118+ expect ( cli ) . to . have . stderr ( "" ) ;
119+ expect ( cli ) . to . have . stdout ( manifest . version + "\n" ) ;
120120 } ) ;
121121 } ) ;
122122} ) ;
0 commit comments