Skip to content

Commit

Permalink
added test for tapEscape function
Browse files Browse the repository at this point in the history
  • Loading branch information
pulkit-30 committed Dec 8, 2022
1 parent 7ac8cba commit b3bc57f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/internal/test_runner/tap_stream.js
Expand Up @@ -270,4 +270,4 @@ function isAssertionLike(value) {
return value && typeof value === 'object' && 'expected' in value && 'actual' in value;
}

module.exports = { TapStream };
module.exports = { TapStream, tapEscape };
15 changes: 15 additions & 0 deletions test/parallel/test-runner-tap-parser-stream.js
Expand Up @@ -4,6 +4,7 @@ const common = require('../common');
const assert = require('node:assert');
const { TapParser } = require('internal/test_runner/tap_parser');
const { TapChecker } = require('internal/test_runner/tap_checker');
const { tapEscape } = require('internal/test_runner/tap_stream');

const cases = [
{
Expand Down Expand Up @@ -627,3 +628,17 @@ ok 1 - test 1
expected.map((item) => ({ __proto__: null, ...item }))
);
})().then(common.mustCall());

(async () => {
[{ escapeChar: '\\', tappedEscape: '\\\\' },
{ escapeChar: '#', tappedEscape: '\\#' },
{ escapeChar: '\n', tappedEscape: '\\n' },
{ escapeChar: '\t', tappedEscape: '\\t' },
{ escapeChar: '\r', tappedEscape: '\\r' },
{ escapeChar: '\f', tappedEscape: '\\f' },
{ escapeChar: '\b', tappedEscape: '\\b' },
{ escapeChar: '\v', tappedEscape: '\\v' },
].forEach(({ escapeChar, tappedEscape }) => {
assert.strictEqual(tapEscape(escapeChar), tappedEscape);
});
})().then(common.mustCall());

0 comments on commit b3bc57f

Please sign in to comment.