Skip to content

Commit

Permalink
[Tests] add tests for 'todo' exit codes
Browse files Browse the repository at this point in the history
  • Loading branch information
r0mflip committed May 26, 2019
1 parent 2c6818a commit c6c4ace
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
54 changes: 54 additions & 0 deletions test/exit.js
Expand Up @@ -148,3 +148,57 @@ tap.test('more planned in a second test', function (t) {
t.notEqual(code, 0);
});
});

tap.test('todo passing', function (t) {
t.plan(2);

var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# todo pass',
'ok 1 should be truthy # TODO',
'',
'1..1',
'# tests 1',
'# pass 1',
'',
'# ok'
].join('\n') + '\n\n');
};

var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.equal(code, 0);
});
});

tap.test('todo failing', function (t) {
t.plan(2);

var tc = function (rows) {
t.same(stripFullStack(rows.toString('utf8')), [
'TAP version 13',
'# todo fail',
'not ok 1 should be truthy # TODO',
' ---',
' operator: ok',
' expected: true',
' actual: false',
' at: Test.<anonymous> ($TEST/exit/todo_fail.js:$LINE:$COL)',
' ...',
'',
'1..1',
'# tests 1',
'# pass 1',
'',
'# ok'
].join('\n') + '\n\n');
};

var ps = spawn(process.execPath, [path.join(__dirname, '/exit/todo_fail.js')]);
ps.stdout.pipe(concat(tc));
ps.on('exit', function (code) {
t.equal(code, 0);
});
});
6 changes: 6 additions & 0 deletions test/exit/todo.js
@@ -0,0 +1,6 @@
var test = require('../../');

test('todo pass', { todo: true }, function (t) {
t.plan(1);
t.ok(true);
});
6 changes: 6 additions & 0 deletions test/exit/todo_fail.js
@@ -0,0 +1,6 @@
var test = require('../../');

test('todo fail', { todo: true }, function (t) {
t.plan(1);
t.ok(false);
});

0 comments on commit c6c4ace

Please sign in to comment.