@@ -21,34 +21,40 @@ const cli = (args, options) => {
21
21
} ;
22
22
23
23
test ( 'should throw when called without [input]' , async t => {
24
- const cwd = await git . bootstrap ( 'fixtures/empty ' ) ;
24
+ const cwd = await git . bootstrap ( 'fixtures/default ' ) ;
25
25
const actual = await cli ( [ ] , { cwd} ) ( ) ;
26
26
t . is ( actual . code , 1 ) ;
27
27
} ) ;
28
28
29
29
test ( 'should reprint input from stdin' , async t => {
30
- const cwd = await git . bootstrap ( 'fixtures/empty ' ) ;
30
+ const cwd = await git . bootstrap ( 'fixtures/default ' ) ;
31
31
const actual = await cli ( [ ] , { cwd} ) ( 'foo: bar' ) ;
32
32
t . true ( actual . stdout . includes ( 'foo: bar' ) ) ;
33
33
} ) ;
34
34
35
35
test ( 'should produce no success output with --quiet flag' , async t => {
36
- const cwd = await git . bootstrap ( 'fixtures/empty ' ) ;
36
+ const cwd = await git . bootstrap ( 'fixtures/default ' ) ;
37
37
const actual = await cli ( [ '--quiet' ] , { cwd} ) ( 'foo: bar' ) ;
38
38
t . is ( actual . stdout , '' ) ;
39
39
t . is ( actual . stderr , '' ) ;
40
40
} ) ;
41
41
42
42
test ( 'should produce no success output with -q flag' , async t => {
43
- const cwd = await git . bootstrap ( 'fixtures/empty ' ) ;
43
+ const cwd = await git . bootstrap ( 'fixtures/default ' ) ;
44
44
const actual = await cli ( [ '-q' ] , { cwd} ) ( 'foo: bar' ) ;
45
45
t . is ( actual . stdout , '' ) ;
46
46
t . is ( actual . stderr , '' ) ;
47
47
} ) ;
48
48
49
- test ( 'should succeed for input from stdin without rules' , async t => {
49
+ test ( 'should fail for input from stdin without rules' , async t => {
50
50
const cwd = await git . bootstrap ( 'fixtures/empty' ) ;
51
51
const actual = await cli ( [ ] , { cwd} ) ( 'foo: bar' ) ;
52
+ t . is ( actual . code , 1 ) ;
53
+ } ) ;
54
+
55
+ test ( 'should succeed for input from stdin with rules' , async t => {
56
+ const cwd = await git . bootstrap ( 'fixtures/default' ) ;
57
+ const actual = await cli ( [ ] , { cwd} ) ( 'type: bar' ) ;
52
58
t . is ( actual . code , 0 ) ;
53
59
} ) ;
54
60
@@ -118,17 +124,20 @@ test('should work with husky via commitlint -e $GIT_PARAMS', async () => {
118
124
await execa ( 'git' , [ 'commit' , '-m' , '"test: this should work"' ] , { cwd} ) ;
119
125
} ) ;
120
126
121
- test ( 'should work with husky via commitlint -e %GIT_PARAMS%' , async ( ) => {
122
- const cwd = await git . bootstrap ( 'fixtures/husky/integration' ) ;
123
- await writePkg ( { scripts : { commitmsg : `'${ bin } ' -e %GIT_PARAMS%` } } , { cwd} ) ;
127
+ test . failing (
128
+ 'should work with husky via commitlint -e %GIT_PARAMS%' ,
129
+ async ( ) => {
130
+ const cwd = await git . bootstrap ( 'fixtures/husky/integration' ) ;
131
+ await writePkg ( { scripts : { commitmsg : `'${ bin } ' -e %GIT_PARAMS%` } } , { cwd} ) ;
124
132
125
- await execa ( 'npm' , [ 'install' ] , { cwd} ) ;
126
- await execa ( 'git' , [ 'add' , 'package.json' ] , { cwd} ) ;
127
- await execa ( 'git' , [ 'commit' , '-m' , '"test: this should work"' ] , { cwd} ) ;
128
- } ) ;
133
+ await execa ( 'npm' , [ 'install' ] , { cwd} ) ;
134
+ await execa ( 'git' , [ 'add' , 'package.json' ] , { cwd} ) ;
135
+ await execa ( 'git' , [ 'commit' , '-m' , '"test: this should work"' ] , { cwd} ) ;
136
+ }
137
+ ) ;
129
138
130
139
test ( 'should allow reading of environment variables for edit file, succeeding if valid' , async t => {
131
- const cwd = await git . bootstrap ( ) ;
140
+ const cwd = await git . bootstrap ( 'fixtures/simple' ) ;
132
141
await sander . writeFile ( cwd , 'commit-msg-file' , 'foo' ) ;
133
142
const actual = await cli ( [ '--env' , 'variable' ] , {
134
143
cwd,
@@ -230,8 +239,8 @@ test('should print full commit message when input from stdin fails', async t =>
230
239
} ) ;
231
240
232
241
test ( 'should not print full commit message when input succeeds' , async t => {
233
- const cwd = await git . bootstrap ( 'fixtures/empty ' ) ;
234
- const message = 'foo : bar\n\nFoo bar bizz buzz.\n\nCloses #123.' ;
242
+ const cwd = await git . bootstrap ( 'fixtures/default ' ) ;
243
+ const message = 'type : bar\n\nFoo bar bizz buzz.\n\nCloses #123.' ;
235
244
const actual = await cli ( [ ] , { cwd} ) ( message ) ;
236
245
237
246
t . false ( actual . stdout . includes ( message ) ) ;
@@ -264,17 +273,27 @@ test('should fail for invalid formatters from flags', async t => {
264
273
} ) ;
265
274
266
275
test ( 'should work with absolute formatter path' , async t => {
267
- const formatterPath = path . resolve ( __dirname , '../fixtures/custom-formatter/formatters/custom.js' ) ;
276
+ const formatterPath = path . resolve (
277
+ __dirname ,
278
+ '../fixtures/custom-formatter/formatters/custom.js'
279
+ ) ;
268
280
const cwd = await git . bootstrap ( 'fixtures/custom-formatter' ) ;
269
- const actual = await cli ( [ '--format' , formatterPath ] , { cwd} ) ( 'test: this should work' ) ;
281
+ const actual = await cli ( [ '--format' , formatterPath ] , { cwd} ) (
282
+ 'test: this should work'
283
+ ) ;
270
284
271
285
t . true ( actual . stdout . includes ( 'custom-formatter-ok' ) ) ;
272
286
t . is ( actual . code , 0 ) ;
273
287
} ) ;
274
288
275
289
test ( 'should work with relative formatter path' , async t => {
276
- const cwd = path . resolve ( await git . bootstrap ( 'fixtures/custom-formatter' ) , './formatters' ) ;
277
- const actual = await cli ( [ '--format' , './custom.js' ] , { cwd} ) ( 'test: this should work' ) ;
290
+ const cwd = path . resolve (
291
+ await git . bootstrap ( 'fixtures/custom-formatter' ) ,
292
+ './formatters'
293
+ ) ;
294
+ const actual = await cli ( [ '--format' , './custom.js' ] , { cwd} ) (
295
+ 'test: this should work'
296
+ ) ;
278
297
279
298
t . true ( actual . stdout . includes ( 'custom-formatter-ok' ) ) ;
280
299
t . is ( actual . code , 0 ) ;
0 commit comments