-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
64 lines (46 loc) · 1.2 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
const test = require('tape')
const markdownTitle = require('./')
let earlyTitle = `
# Title
Some text!
# Another H1, who does this?
`
let lateTitle = `
I want to write an intro first
# Title comes late
Then more text
`
let manySpaces = `
# Title prefixed with lots of space
`
let closingPound = `
# Title with closing pound mark #
`
let poundMarksInside = `
# Title with pound marks ## inside
`
let superMessyTitle = `
Let’s make it a bit harder
## Not getting props for a11y either
# Title is kind # of messy but still valid ####
See?
`
let textOnly = `
I only wrote text
## And possibly a H2
`
let noTextAtAll = ``
test('Finds titles', t => {
t.plan(6)
t.equal(markdownTitle(earlyTitle), 'Title')
t.equal(markdownTitle(lateTitle), 'Title comes late')
t.equal(markdownTitle(manySpaces), 'Title prefixed with lots of space')
t.equal(markdownTitle(closingPound), 'Title with closing pound mark')
t.equal(markdownTitle(poundMarksInside), 'Title with pound marks ## inside')
t.equal(markdownTitle(superMessyTitle), 'Title is kind # of messy but still valid')
})
test('Doesn’t find titles', t => {
t.plan(2)
t.false(markdownTitle(textOnly))
t.false(markdownTitle(noTextAtAll))
})