-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
60 lines (52 loc) · 1.96 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
import test from 'node:test'
import assert from 'node:assert'
import concat from 'simple-concat'
import mdinsert from './index.js'
test('header', function (t, done) {
const s = mdinsert({
header: 'Cool Things',
content: 'Interesting content'
})
concat(s, function (e, result) {
assert.ifError(e)
assert.equal(result + '', '# Title\n\n## Cool Things\nInteresting content\n\n# Uncool things\nUninteresting content\n')
done()
})
s.end('# Title\n\n## Cool Things\nblah blah\n\n# Uncool things\nUninteresting content\n')
})
test('header with trailing newline', function (t, done) {
const s = mdinsert({
header: 'Cool Things',
content: 'Interesting content\n'
})
concat(s, function (e, result) {
assert.ifError(e)
assert.equal(result + '', '# Title\n\n## Cool Things\nInteresting content\n\n# Uncool things\nUninteresting content\n')
done()
})
s.end('# Title\n\n## Cool Things\nblah blah\n\n# Uncool things\nUninteresting content\n')
})
test('region', function (t, done) {
const s = mdinsert({
region: 'insert',
content: 'Interesting content'
})
concat(s, function (e, result) {
assert.ifError(e)
assert.equal(result + '', '# Title\n\n## Cool Things\n<!--insert start-->\nInteresting content\n<!--insert end-->\n\n# Uncool things\nUninteresting content\n')
done()
})
s.end('# Title\n\n## Cool Things\n<!--insert start-->\nblah blah\n<!--insert end-->\n\n# Uncool things\nUninteresting content\n')
})
test('region with trailing newline', function (t, done) {
const s = mdinsert({
region: 'insert',
content: 'Interesting content\n'
})
concat(s, function (e, result) {
assert.ifError(e)
assert.equal(result + '', '# Title\n\n## Cool Things\n<!--insert start-->\nInteresting content\n\n<!--insert end-->\n\n# Uncool things\nUninteresting content\n')
done()
})
s.end('# Title\n\n## Cool Things\n<!--insert start-->\nblah blah\n<!--insert end-->\n\n# Uncool things\nUninteresting content\n')
})