Skip to content

Commit

Permalink
Merge pull request #9 from gabrielcsapo/fixes-#8
Browse files Browse the repository at this point in the history
[bug] fixes issue with plan not checking for plan name to be a string and instead uses range
  • Loading branch information
gabrielcsapo authored Mar 5, 2019
2 parents c5f4b61 + c0eb810 commit 4a3748b
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/example/index.html

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ module.exports = function tapHTML(callback) {
});

tap.on('plan', (res) => {
if(typeof res !== 'string') return;

plan = res;
});

Expand Down
12 changes: 12 additions & 0 deletions report.html

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions test/fixtures/test-with-plan-as-range.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
1..2
# Some description of a test
ok 1 Yep a test description
# Some other description of a test
ok 2 And this one is another test description
42 changes: 41 additions & 1 deletion test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,47 @@ const path = require('path');
const parser = require('../index');

test('tap-html', (t) => {
t.plan(3);
t.plan(4);

t.test('should be able to parse test that starts with range', (t) => {
const testWithPlanAsRange = fs.createReadStream(path.resolve(__dirname, './fixtures/test-with-plan-as-range.txt'));
testWithPlanAsRange.pipe(parser((res) => {
t.equal(res.ok, true);
t.equal(res.count, 2);
t.equal(res.pass, 2);
t.equal(res.fail, 0);
t.equal(res.bailout, false);
t.equal(res.todo, 0);
t.equal(res.skip, 0);
t.deepEqual(res.plan, {
"start": 1,
"end": 2,
"skipAll": false,
"skipReason": "",
"comment": ""
});
t.deepEqual(res.failures, []);
t.equal(res.tests.length, 2);
t.equal(res.tests[0].type, 'test');
t.equal(res.tests[0].name, '# Some description of a test');
t.equal(res.tests[0].assertions.length, 1);
t.equal(res.tests[0].assertions[0].type, 'assert');
t.equal(res.tests[0].assertions[0].number, 1);
t.equal(res.tests[0].assertions[0].name, 'Yep a test description');
t.equal(res.tests[0].assertions[0].ok, true);
t.equal(res.tests[0].assertions[0].console, '');

t.equal(res.tests[1].type, 'test');
t.equal(res.tests[1].name, '# Some other description of a test');
t.equal(res.tests[1].assertions.length, 1);
t.equal(res.tests[1].assertions[0].type, 'assert');
t.equal(res.tests[1].assertions[0].number, 2);
t.equal(res.tests[1].assertions[0].name, 'And this one is another test description');
t.equal(res.tests[1].assertions[0].ok, true);
t.equal(res.tests[1].assertions[0].console, '');
t.end();
}));
});

t.test('should be able to parse flat test', (t) => {
const flat = fs.createReadStream(path.resolve(__dirname, './fixtures/flat.txt'));
Expand Down

0 comments on commit 4a3748b

Please sign in to comment.