UNPKG

1.01 kBJavaScriptView Raw
1'use strict';
2const tap = require('tap');
3const main = require('../index.js');
4const path = require('path');
5
6let results = [];
7
8tap.beforeEach((done) => {
9 results = [];
10 console.log = (input) => {
11 results.push(input);
12 };
13 done();
14});
15
16tap.afterEach((done) => {
17 done();
18});
19
20tap.test(' loads and runs the default task with printout', async(t) => {
21 process.env.TASKKIT_PREFIX = 'default';
22 process.env.TASKKIT_CONFIG = path.join(__dirname, 'conf');
23 await main();
24 t.equal(results[0].endsWith('free :: Running free...'), true);
25 t.notEqual(results[2].indexOf('free :: Finished in'), -1);
26 t.end();
27});
28
29tap.test(' loads and runs a named task with printout', async(t) => {
30 process.env.TASKKIT_PREFIX = 'default';
31 process.env.TASKKIT_CONFIG = path.join(__dirname, 'conf');
32 await main('ls');
33 const output = results[1].split('\n');
34 t.notEqual(output.indexOf('example'), -1);
35 t.notEqual(output.indexOf('node_modules'), -1);
36 t.notEqual(output.indexOf('index.js'), -1);
37 t.end();
38});