@@ -31,7 +31,7 @@ const exec = (command, args = [], opts = {}) => {
31
31
console . log ( result . stderr ) ;
32
32
}
33
33
return result ;
34
- }
34
+ } ;
35
35
} ;
36
36
37
37
const cli = exec . bind ( null , CLI ) ;
@@ -40,8 +40,12 @@ const mkdir = exec.bind(null, bin('mkdirp'));
40
40
const npm = exec . bind ( null , 'npm' ) ;
41
41
const rm = exec . bind ( null , bin ( 'rimraf' ) ) ;
42
42
43
- test ( 'should throw when called without [input]' , t => {
44
- t . throws ( cli ( ) ( ) , / E x p e c t e d a r a w c o m m i t / ) ;
43
+ test ( 'should throw when called without [input]' , async t => {
44
+ const dir = tmp . dirSync ( ) . name ;
45
+
46
+ await init ( dir ) ;
47
+ await t . throws ( cli ( [ ] , { cwd : dir } ) ( ) , / E x p e c t e d a r a w c o m m i t / ) ;
48
+ await rm ( [ dir ] ) ( ) ;
45
49
} ) ;
46
50
47
51
test ( 'should reprint input from stdin' , async t => {
@@ -73,11 +77,19 @@ test('should fail for input from stdin with rule from rc', async t => {
73
77
} ) ;
74
78
75
79
test ( 'should fail for input from stdin with rule from js' , async t => {
80
+ const dir = tmp . dirSync ( ) . name ;
81
+
82
+ await init ( dir ) ;
83
+ await sander . copydir ( EXTENDS_ROOT ) . to ( dir ) ;
84
+
76
85
const actual = await t . throws (
77
- cli ( [ '--extends' , './extended' ] , { cwd : EXTENDS_ROOT } ) ( 'foo: bar' )
86
+ cli ( [ '--extends' , './extended' ] , { cwd : dir } ) ( 'foo: bar' )
78
87
) ;
88
+
79
89
t . true ( includes ( actual . stdout , 'type must not be one of [foo]' ) ) ;
80
90
t . is ( actual . code , 1 ) ;
91
+
92
+ await rm ( [ dir ] ) ( ) ;
81
93
} ) ;
82
94
83
95
test ( 'should produce no error output with --quiet flag' , async t => {
@@ -125,11 +137,13 @@ test('should work with husky commitmsg hook in sub packages', async () => {
125
137
126
138
test ( 'should pick up parser preset' , async t => {
127
139
const cwd = PARSER_PRESET ;
128
-
129
140
const actual = await t . throws ( cli ( [ ] , { cwd} ) ( 'type(scope)-ticket subject' ) ) ;
141
+
130
142
t . true ( includes ( actual . stdout , 'message may not be empty [subject-empty]' ) ) ;
131
143
132
- await cli ( [ '--parser-preset' , './parser-preset' ] , { cwd} ) ( 'type(scope)-ticket subject' ) ;
144
+ await cli ( [ '--parser-preset' , './parser-preset' ] , { cwd} ) (
145
+ 'type(scope)-ticket subject'
146
+ ) ;
133
147
} ) ;
134
148
135
149
async function init ( cwd ) {
@@ -142,5 +156,9 @@ async function init(cwd) {
142
156
}
143
157
144
158
function pkg ( cwd ) {
145
- return sander . writeFile ( cwd , 'package.json' , JSON . stringify ( { scripts : { commitmsg : `${ CLI } -e` } } ) ) ;
159
+ return sander . writeFile (
160
+ cwd ,
161
+ 'package.json' ,
162
+ JSON . stringify ( { scripts : { commitmsg : `${ CLI } -e` } } )
163
+ ) ;
146
164
}
0 commit comments