-
Notifications
You must be signed in to change notification settings - Fork 1
/
test.js
56 lines (47 loc) · 1.54 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
var test = require('tape')
var twitterScreenName = require('./')
test('Should extract screen name from screen name', function (t) {
t.plan(1)
t.equal(twitterScreenName('_alanshaw'), '_alanshaw')
t.end()
})
test('Should extract screen name from screen name with @', function (t) {
t.plan(1)
t.equal(twitterScreenName('@_alanshaw'), '_alanshaw')
t.end()
})
test('Should extract screen name from url', function (t) {
t.plan(1)
t.equal(twitterScreenName('http://twitter.com/_alanshaw'), '_alanshaw')
t.end()
})
test('Should extract screen name from url with https', function (t) {
t.plan(1)
t.equal(twitterScreenName('https://twitter.com/_alanshaw'), '_alanshaw')
t.end()
})
test('Should extract screen name from url with www.', function (t) {
t.plan(1)
t.equal(twitterScreenName('http://www.twitter.com/_alanshaw'), '_alanshaw')
t.end()
})
test('Should extract screen name from url with trailing slash', function (t) {
t.plan(1)
t.equal(twitterScreenName('http://twitter.com/_alanshaw/'), '_alanshaw')
t.end()
})
test('Should extract screen name from url with trailing junk', function (t) {
t.plan(1)
t.equal(twitterScreenName('http://twitter.com/_alanshaw/status/695527644901801984'), '_alanshaw')
t.end()
})
test('Should not extract screen name from non twiiter url', function (t) {
t.plan(1)
t.notOk(twitterScreenName('http://example.org/_alanshaw'))
t.end()
})
test('Should not extract screen name from invalid screen name', function (t) {
t.plan(1)
t.notOk(twitterScreenName('toolongfortwitter'))
t.end()
})