11import test from 'ava' ;
22import execa from 'execa' ;
3+ import isSemver from 'is-semver' ;
34
4- test ( 'Unknown command' , async t => {
5+ test ( '" Unknown command" ' , async t => {
56 const result = await t . throws ( execa ( './cli.js' , [ 'Hej' ] ) ) ;
67 t . is ( result . code , 127 ) ;
78 t . regex ( result . stderr , / H e j : .+ n o t f o u n d / ) ;
@@ -22,23 +23,55 @@ test('"Command which exits properly with exit code 0"', async t => {
2223 t . is ( result . stderr , '' ) ;
2324} ) ;
2425
25- test ( 'No input given' , async t => {
26+ test ( '" No input given" ' , async t => {
2627 const result = await t . throws ( execa ( './cli.js' , [ ] ) ) ;
2728 t . is ( result . code , 2 ) ;
2829 t . regex ( result . stdout , / I n v a l i d i n p u t . P l e a s e c h e c k t h e h e l p b e l o w : / ) ;
2930 t . regex ( result . stdout , / U s a g e / ) ;
3031} ) ;
3132
32- test ( 'To much input' , async t => {
33+ test ( '" To much input" ' , async t => {
3334 const result = await t . throws ( execa ( './cli.js' , [ 'Hu' , 'Ha' ] ) ) ;
3435 t . is ( result . code , 2 ) ;
3536 t . regex ( result . stdout , / I n v a l i d i n p u t . P l e a s e c h e c k t h e h e l p b e l o w : / ) ;
3637 t . regex ( result . stdout , / U s a g e / ) ;
3738} ) ;
3839
39- test ( 'wrong options' , async t => {
40+ test ( '" wrong options" ' , async t => {
4041 const result = await t . throws ( execa ( './cli.js' , [ 'echo Hej' , '-p' ] ) ) ;
4142 t . is ( result . code , 2 ) ;
4243 t . regex ( result . stdout , / W r o n g o p t i o n \( s \) p r o v i d e d . P l e a s e c h e c k t h e h e l p b e l o w : / ) ;
4344 t . regex ( result . stdout , / U s a g e / ) ;
4445} ) ;
46+
47+ test ( '"Show version number via flag"' , async t => {
48+ await t . notThrows ( execa ( './cli.js' , [ '--version' ] ) ) ;
49+ const result = await execa ( './cli.js' , [ '--version' ] ) ;
50+ t . true ( isSemver ( result . stdout ) ) ;
51+ t . is ( result . code , 0 ) ;
52+ t . is ( result . stderr , '' ) ;
53+ } ) ;
54+
55+ test ( '"Show version number via alias"' , async t => {
56+ await t . notThrows ( execa ( './cli.js' , [ '-v' ] ) ) ;
57+ const result = await execa ( './cli.js' , [ '-v' ] ) ;
58+ t . true ( isSemver ( result . stdout ) ) ;
59+ t . is ( result . code , 0 ) ;
60+ t . is ( result . stderr , '' ) ;
61+ } ) ;
62+
63+ test ( '"Show help via flag"' , async t => {
64+ await t . notThrows ( execa ( './cli.js' , [ '--help' ] ) ) ;
65+ const result = await execa ( './cli.js' , [ '--help' ] ) ;
66+ t . regex ( result . stdout , / ^ \n { 2 } S e n d s n a t i v e d e s k t o p n o t i f i c a t i o n s / m) ;
67+ t . is ( result . code , 0 ) ;
68+ t . is ( result . stderr , '' ) ;
69+ } ) ;
70+
71+ test ( '"Show help via alias"' , async t => {
72+ await t . notThrows ( execa ( './cli.js' , [ '-h' ] ) ) ;
73+ const result = await execa ( './cli.js' , [ '-h' ] ) ;
74+ t . regex ( result . stdout , / ^ \n { 2 } S e n d s n a t i v e d e s k t o p n o t i f i c a t i o n s / m) ;
75+ t . is ( result . code , 0 ) ;
76+ t . is ( result . stderr , '' ) ;
77+ } ) ;
0 commit comments