Skip to content

Commit b3bc57f

Browse files
committed
added test for tapEscape function
1 parent 7ac8cba commit b3bc57f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

lib/internal/test_runner/tap_stream.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,4 +270,4 @@ function isAssertionLike(value) {
270270
return value && typeof value === 'object' && 'expected' in value && 'actual' in value;
271271
}
272272

273-
module.exports = { TapStream };
273+
module.exports = { TapStream, tapEscape };

test/parallel/test-runner-tap-parser-stream.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const common = require('../common');
44
const assert = require('node:assert');
55
const { TapParser } = require('internal/test_runner/tap_parser');
66
const { TapChecker } = require('internal/test_runner/tap_checker');
7+
const { tapEscape } = require('internal/test_runner/tap_stream');
78

89
const cases = [
910
{
@@ -627,3 +628,17 @@ ok 1 - test 1
627628
expected.map((item) => ({ __proto__: null, ...item }))
628629
);
629630
})().then(common.mustCall());
631+
632+
(async () => {
633+
[{ escapeChar: '\\', tappedEscape: '\\\\' },
634+
{ escapeChar: '#', tappedEscape: '\\#' },
635+
{ escapeChar: '\n', tappedEscape: '\\n' },
636+
{ escapeChar: '\t', tappedEscape: '\\t' },
637+
{ escapeChar: '\r', tappedEscape: '\\r' },
638+
{ escapeChar: '\f', tappedEscape: '\\f' },
639+
{ escapeChar: '\b', tappedEscape: '\\b' },
640+
{ escapeChar: '\v', tappedEscape: '\\v' },
641+
].forEach(({ escapeChar, tappedEscape }) => {
642+
assert.strictEqual(tapEscape(escapeChar), tappedEscape);
643+
});
644+
})().then(common.mustCall());

0 commit comments

Comments
 (0)