@@ -4,16 +4,28 @@ import * as cproc from 'child_process';
44
55const exec = util . promisify ( cproc . exec ) ;
66
7- test ( 'runs tests ' , async ( t ) => {
8- const command = './bin/hayspec test --require ts-node/register --match ./src/tests/assets/**/*.hay.*' ;
7+ test ( 'initializes current folder ' , async ( t ) => {
8+ const command = `mkdir -p ./node_modules/.tmp/ test; cd ./node_modules/.tmp/test; ../../../bin/hayspec init --name foo --description bar; echo code: $?` ;
99 const { stdout, stderr } = await exec ( command ) ;
10- t . true ( stdout . indexOf ( 'src/tests/assets/foo.hay.ts' ) !== - 1 ) ;
10+ t . true ( stdout . indexOf ( 'Continue by running the commands below:' ) !== - 1 ) ;
11+ t . true ( stdout . indexOf ( 'code: 0' ) !== - 1 ) ;
1112 t . true ( stderr === '' ) ;
1213} ) ;
1314
14- test ( 'initializes current folder ' , async ( t ) => {
15- const command = `mkdir -p ./node_modules/.tmp/ test; cd ./node_modules/.tmp/test; ../../../bin/hayspec init --name foo --description bar` ;
15+ test ( 'runs valid tests ' , async ( t ) => {
16+ const command = './bin/hayspec test --require ts-node/register --match ./src/tests/assets/**/valid.hay.*; echo code: $?' ;
1617 const { stdout, stderr } = await exec ( command ) ;
17- t . true ( stdout . indexOf ( 'Continue by running the commands below:' ) !== - 1 ) ;
18+ t . true ( stdout . indexOf ( 'src/tests/assets/valid.hay.ts' ) !== - 1 ) ;
19+ t . true ( stdout . indexOf ( 'src/tests/assets/invalid.hay.ts' ) === - 1 ) ;
20+ t . true ( stdout . indexOf ( 'code: 0' ) !== - 1 ) ;
21+ t . true ( stderr === '' ) ;
22+ } ) ;
23+
24+ test ( 'runs invalid tests' , async ( t ) => {
25+ const command = './bin/hayspec test --require ts-node/register --match ./src/tests/assets/**/invalid.hay.*; echo code: $?' ;
26+ const { stdout, stderr } = await exec ( command ) ;
27+ t . true ( stdout . indexOf ( 'src/tests/assets/valid.hay.ts' ) === - 1 ) ;
28+ t . true ( stdout . indexOf ( 'src/tests/assets/invalid.hay.ts' ) !== - 1 ) ;
29+ t . true ( stdout . indexOf ( 'code: 1' ) !== - 1 ) ;
1830 t . true ( stderr === '' ) ;
1931} ) ;
0 commit comments