-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
80 lines (73 loc) · 1.55 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
71
72
73
74
75
76
77
78
79
80
var test = require('tape'),
extract = require('./name-extractor')
test('simple', function (t) {
t.deepEqual(
extract('beep Hello World boop').sort()
, [
'Hello'
, 'Hello World'
, 'World'
]
)
t.end()
})
test('include title minor-case words', function (t) {
t.deepEqual(
extract('they were playing Crying at the Discoteque yesterday').sort()
, [
'Crying'
, 'Crying at'
, 'Crying at the'
, 'Crying at the Discoteque'
, 'Discoteque'
, 'at the Discoteque'
, 'the Discoteque'
]
)
t.end()
})
test('include some crazy spacing', function (t) {
t.deepEqual(
extract(' \t the\r\tHello\t\t\t\n World\t\r\t').sort()
, [
'Hello'
, 'Hello World'
, 'World'
, 'the Hello'
, 'the Hello World'
]
)
t.end()
})
test('when a title-minor-word is at the end of a sentence', function (t) {
t.deepEqual(
extract('You\'re out!').sort()
, [
'You\'re'
, 'You\'re out!'
]
)
t.deepEqual(
extract('Hello in.beep')
, [ 'Hello' ]
)
t.end()
})
test('Allow names to have dots and stuff in them', function (t) {
t.deepEqual(
extract('Hello. World! Foo... BAR!?!').sort()
, [
'BAR!?!'
, 'Foo...'
, 'Foo... BAR!?!'
, 'Hello.'
, 'Hello. World!'
, 'Hello. World! Foo...'
, 'Hello. World! Foo... BAR!?!'
, 'World!'
, 'World! Foo...'
, 'World! Foo... BAR!?!'
]
)
t.end()
})