forked from github-tools/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.spec.js
More file actions
135 lines (109 loc) · 3.86 KB
/
user.spec.js
File metadata and controls
135 lines (109 loc) · 3.86 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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import expect from 'must';
import Github from '../lib/GitHub';
import testUser from './fixtures/user.js';
import {assertSuccessful, assertArray} from './helpers/callbacks';
describe('User', function() {
let github;
let user;
before(function() {
github = new Github({
username: testUser.USERNAME,
password: testUser.PASSWORD,
auth: 'basic',
});
user = github.getUser();
});
it('should get user repos', function(done) {
user.listRepos(assertArray(done));
});
it('should get user repos with options', function(done) {
const filterOpts = {
type: 'owner',
sort: 'updated',
per_page: 90, // eslint-disable-line
page: 10,
};
user.listRepos(filterOpts, assertArray(done));
});
it('should get user orgs', function(done) {
user.listOrgs(assertArray(done));
});
it('should get user followers', function(done) {
user.listFollowers(assertArray(done));
});
it('should get user following list', function(done) {
user.listFollowing(assertArray(done));
});
it('should get user gists', function(done) {
user.listGists(assertArray(done));
});
it('should get user notifications', function(done) {
user.listNotifications(assertArray(done));
});
it('should get user notifications with options', function(done) {
const filterOpts = {
all: true,
participating: true,
since: '2015-01-01T00:00:00Z',
before: '2015-02-01T00:00:00Z',
};
user.listNotifications(filterOpts, assertArray(done));
});
it('should get the user\'s profile', function(done) {
user.getProfile(assertSuccessful(done));
});
it('should show user\'s starred repos', function(done) {
user.listStarredRepos(assertArray(done));
});
it('should show user\'s starred gists', function(done) {
const option = {
since: '2015-01-01T00:00:00Z',
};
user.listStarredGists(option, assertArray(done));
});
describe('following a user', function() {
const userToFollow = 'ingalls';
before(function() {
return user.unfollow(userToFollow);
});
it('should follow user', function(done) {
user.follow(userToFollow, assertSuccessful(done, function(err, resp) {
user._request('GET', '/user/following', null, assertSuccessful(done, function(err, following) {
expect((following.some((user) => user['login'] === userToFollow))).to.be.true();
done();
}));
}));
});
});
describe('following yourself', function() {
const userToFollow = testUser.USERNAME;
before(function() {
return user.unfollow(userToFollow);
});
it('should not list yourself as one of your followers', function(done) {
user.follow(userToFollow, assertSuccessful(done, function(err, resp) {
user._request('GET', '/user/following', null, assertSuccessful(done, function(err, following) {
expect((following.some((user) => user['login'] === userToFollow))).to.be.false();
done();
}));
}));
});
});
describe('unfollowing a user', function(done) {
const userToUnfollow = 'ingalls';
before(function() {
return user.follow(userToUnfollow);
});
it('should unfollow a user', function(done) {
user.unfollow(userToUnfollow, assertSuccessful(done, function(err, resp) {
user._request('GET', '/user/following', null, assertSuccessful(done, function(err, following) {
expect((following.some((user) => user['login'] === userToUnfollow))).to.be.false();
done();
}));
}));
});
});
it('should list the email addresses of the user', function(done) {
user.getEmails(assertSuccessful(done));
});
});