From 321dc64468940f6fb59bacc775f5e7e2a940a51e Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Sat, 25 Jun 2022 21:07:48 +0200 Subject: [PATCH] Add test for performance Related-to: syntax-tree/mdast-util-to-hast#62. Co-authored-by: Nathaniel Hunter <42shadow42@gmail.com> --- test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test.js b/test.js index de89bda..7bbca2d 100644 --- a/test.js +++ b/test.js @@ -11,3 +11,21 @@ test('trimLines(value)', function (t) { ) t.end() }) + +test('efficiency', (t) => { + const aTonOfWhitespace = 'a' + ' '.repeat(70_000) + 'b' + const timeoutId = setTimeout(() => { + t.fail('should process lots of whitespace efficiently') + }, 10) + + t.deepEqual( + trimLines(aTonOfWhitespace), + aTonOfWhitespace, + 'should be efficient on excessive whitespace' + ) + + setTimeout(() => { + clearTimeout(timeoutId) + t.end() + }, 0) +})