-
Notifications
You must be signed in to change notification settings - Fork 94
/
issue.test.js
53 lines (48 loc) 路 1.92 KB
/
issue.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
var test = require('tape');
var issue = require('../lib/switcher');
test('Scrape /dwyl/tudo/issues/51 for comments & meta-data', function (t) {
var url = '/dwyl/tudo/issues/51';
issue(url, function(err, data) {
console.log(data)
t.ok(data.url.indexOf(url) > -1, url + ' is: ' +data.url)
t.ok(data.title.length > 0, url + ' has title: '+data.title);
t.ok(data.state.length > 0, url + ' is: '+data.state);
t.ok(data.author.length > 0, url + ' was authored by: '+data.author);
t.ok(data.created.length > 0, url + ' was created on: '+data.created);
// labels
t.ok(data.labels.length > 2, url + ' has '+data.labels.length + ' labels')
t.ok(data.milestone === 'Minimal Usable Product', 'Milestone is: '
+ data.milestone);
t.ok(data.assignee.length > 0, url + ' has assignee: '+ data.assignee);
t.ok(data.participants.length > 2, url + ' has participants: '
+ data.participants);
t.ok(data.participants.indexOf('iteles') > -1, url
+ ' has participation from @iteles');
// t.ok(data.entries.length > 2,
// url + ' has: '+data.entries.length + ' comments');
t.end();
});
})
test.skip('Scrape known issue without assignee', function(t) {
var url ='/1602/compound/issues/20'
issue(url, function(err, data){
t.ok(typeof data.assignee === 'undefined', "assignee is undefined")
t.ok(data.state === 'Closed', url +' state is: ' + data.state)
t.end()
});
})
test.skip('Scrape known issue without milestone', function(t){
var url = '/dwyl/time/issues/154';
issue(url, function(err, data){
console.log(data);
var d = data.entries.filter(function(item){
return item.id === 'issuecomment-104228711';
})
d = d[0] // there should only be one entry
t.ok(data.state === 'Closed', url +' state is: ' + data.state)
var dash = ' - - - - - - - - - - - - '
var easter_egg = '\n' + dash +'> '+ d.body +' <' + dash +'\n'
t.ok(d.body === 'I Love you!', url +' last comment is: '+easter_egg);
t.end()
});
})