This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
test.js
70 lines (61 loc) · 1.43 KB
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const assert = require('assert')
const theredoc = require('./index')
module.exports = {
'no indents -> no op' () {
assert.equal(theredoc``, '')
assert.equal(theredoc`Hi`, 'Hi')
assert.equal(theredoc`A
long
hello`, `A
long
hello`)
assert.equal(theredoc`first
line separate`, `first
line separate`)
},
'min indent uniformly stripped' () {
assert.equal(theredoc`
Hey, I'm doing my best
…I know
Cool
`, `Hey, I'm doing my best
…I know
Cool`)
},
'strips exactly one leading and one trailing line' () {
assert.equal(theredoc`\n\n`, '')
assert.equal(theredoc`\nhi\n`, 'hi')
assert.equal(theredoc`\n\n\nhi\n\n`, '\n\nhi\n')
assert.equal(theredoc` \t \n\n\nhi\n\n `, '\n\nhi\n')
assert.equal(theredoc`
love too lead
and also trails
`, `
love too lead
and also trails
`)
},
'whitespace leading and trailing lines do not count toward indent' () {
assert.equal(theredoc` \n hi\n bye`, 'hi\n bye')
},
'nested templates get zipped okay' () {
assert.equal(theredoc`I've ${'just'} got ${3}
${'bananas\n'}
you?`, `I've just got 3
bananas
you?`)
},
'nested theredocs (tho trippy) work inside then out' () {
assert.equal(theredoc`
what if:
${theredoc`
some other message
was right here
`}
then what
`, ` what if:
some other message
was right here
then what`)
}
}