Skip to content

Commit d66c7dd

Browse files
committed
Add test for lots of whitespace around line endings
Related-to: syntax-tree/mdast-util-to-hast#62.
1 parent 9665782 commit d66c7dd

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

test.js

+39-14
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,44 @@ test('trimLines(value)', function (t) {
1313
})
1414

1515
test('efficiency', (t) => {
16-
const aTonOfWhitespace = 'a' + ' '.repeat(70_000) + 'b'
17-
const timeoutId = setTimeout(() => {
18-
t.fail('should process lots of whitespace efficiently')
19-
}, 10)
20-
21-
t.deepEqual(
22-
trimLines(aTonOfWhitespace),
23-
aTonOfWhitespace,
24-
'should be efficient on excessive whitespace'
25-
)
16+
const whitespace = ' '.repeat(70_000)
17+
18+
t.test('whitespace in line', (t) => {
19+
const timeoutId = setTimeout(() => {
20+
t.fail('did not pass in 10ms')
21+
}, 10)
22+
23+
t.deepEqual(trimLines('a' + whitespace + 'b'), 'a' + whitespace + 'b')
24+
25+
setTimeout(() => {
26+
clearTimeout(timeoutId)
27+
t.end()
28+
}, 0)
29+
})
30+
31+
t.test('whitespace around line', (t) => {
32+
const timeoutId = setTimeout(() => {
33+
t.fail('did not pass in 10ms')
34+
}, 10)
35+
36+
t.deepEqual(
37+
trimLines(
38+
'a' +
39+
whitespace +
40+
'\n' +
41+
whitespace +
42+
'b' +
43+
whitespace +
44+
'\n' +
45+
whitespace +
46+
'c'
47+
),
48+
'a\nb\nc'
49+
)
2650

27-
setTimeout(() => {
28-
clearTimeout(timeoutId)
29-
t.end()
30-
}, 0)
51+
setTimeout(() => {
52+
clearTimeout(timeoutId)
53+
t.end()
54+
}, 0)
55+
})
3156
})

0 commit comments

Comments
 (0)