From c6c4aceccf52fb189732b95fd049b4e110d7868f Mon Sep 17 00:00:00 2001 From: Ram Damera Date: Sun, 26 May 2019 18:27:41 +0530 Subject: [PATCH] [Tests] add tests for 'todo' exit codes --- test/exit.js | 54 ++++++++++++++++++++++++++++++++++++++++++ test/exit/todo.js | 6 +++++ test/exit/todo_fail.js | 6 +++++ 3 files changed, 66 insertions(+) create mode 100644 test/exit/todo.js create mode 100644 test/exit/todo_fail.js diff --git a/test/exit.js b/test/exit.js index 283301fc..38cf94df 100644 --- a/test/exit.js +++ b/test/exit.js @@ -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. ($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); + }); +}); diff --git a/test/exit/todo.js b/test/exit/todo.js new file mode 100644 index 00000000..acbf960a --- /dev/null +++ b/test/exit/todo.js @@ -0,0 +1,6 @@ +var test = require('../../'); + +test('todo pass', { todo: true }, function (t) { + t.plan(1); + t.ok(true); +}); diff --git a/test/exit/todo_fail.js b/test/exit/todo_fail.js new file mode 100644 index 00000000..f8ffa67c --- /dev/null +++ b/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); +});