Skip to content

Commit 4487735

Browse files
committed
Add test setup and proof of concept test
1 parent d5a2eb2 commit 4487735

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
},
77
"devDependencies": {
88
"ava": "0.15.2",
9-
"execa": "0.4.0"
9+
"execa": "0.4.0",
10+
"strip-ansi": "3.0.1"
1011
}
1112
}

test/test.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import test from 'ava';
2+
import {default as execa, spawn} from 'execa';
3+
import {readFileSync} from 'fs';
4+
import stripAnsi from 'strip-ansi';
5+
6+
const kcommand = readFileSync('../k.sh', 'utf-8');
7+
8+
function k(path='') {
9+
return execa('eval', [kcommand + 'k ' + path], {shell: '/bin/zsh'})
10+
.then(({stdout}) => stdout)
11+
.then(res => res.split('\n'));
12+
}
13+
14+
k.stripColors = function (path) {
15+
return k(path).then(res => res.map(line => stripAnsi(line)));
16+
}
17+
18+
test('First proof of concept test', t => {
19+
return k.stripColors()
20+
.then(lines => {
21+
t.is(lines[0], 'total 8');
22+
});
23+
});

0 commit comments

Comments
 (0)