-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtests.js
More file actions
52 lines (43 loc) · 1.8 KB
/
tests.js
File metadata and controls
52 lines (43 loc) · 1.8 KB
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
var hn = require('./hackernews');
var assert = require('assert')
//Test getItem
var pull = hn.getItem(8863);
assert.equal(pull.by, 'dhouston');
assert.equal(pull.descendants, 71);
assert.equal(pull.id, 8863);
assert.equal(pull.score, 111);
assert.equal(pull.time, 1175714200);
assert.equal(pull.title, 'My YC app: Dropbox - Throw away your USB drive');
assert.equal(pull.type, 'story');
assert.equal(pull.url, 'http://www.getdropbox.com/u/2/screencast.html');
var pull = hn.getItem('8863');
assert.equal(pull.by, 'dhouston');
assert.equal(pull.descendants, 71);
assert.equal(pull.id, 8863);
assert.equal(pull.score, 111);
assert.equal(pull.time, 1175714200);
assert.equal(pull.title, 'My YC app: Dropbox - Throw away your USB drive');
assert.equal(pull.type, 'story');
assert.equal(pull.url, 'http://www.getdropbox.com/u/2/screencast.html');
assert.equal(hn.getItem(99999999999999999999999999999999999999999999), null)
assert.equal(hn.getItem(0), null)
assert.equal(hn.getItem(-1), null)
//Test getUser
pull = hn.getUser('wcember');
assert.equal(pull.id, 'wcember');
assert.equal(pull.created, 1382846640);
assert.equal(typeof(pull.about), 'string');
assert.equal(typeof(pull.delay), 'number');
assert.equal(typeof(pull.karma), 'number');
assert.equal(typeof(pull.submitted), 'object');
assert.equal(hn.getUser('sdfasdfasdfkjbsadflkjbasdf8rpqbldfkasdfs'), null)
//Test remaining functions
assert.equal(typeof(hn.getMaxItem()), 'number');
assert.equal(typeof(hn.getTopStories()[0]), 'number');
assert.equal(typeof(hn.getNewStories()[0]), 'number');
assert.equal(typeof(hn.getAskStories()[0]), 'number');
assert.equal(typeof(hn.getShowStories()[0]), 'number');
assert.equal(typeof(hn.getJobStories()[0]), 'number');
var pull = hn.getUpdates()
assert.equal(typeof(pull.items[0]), 'number');
assert.equal(typeof(pull.profiles[0]), 'string');