forked from kaiwood/pnut-butter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers_test.js
207 lines (158 loc) · 4.51 KB
/
users_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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
const nock = require("nock");
chai.use(chaiAsPromised);
chai.should();
const expect = chai.expect;
const pnut = require("../lib/pnut");
before(function() {
let base = "https://api.pnut.io/v0";
nock(base)
.get("/users/1")
.reply(200, {});
nock(base)
.get("/users?ids=4,12,1000")
.reply(200, {});
nock(base)
.get("/users/1/mentions")
.reply(200, {});
nock(base)
.get("/users/1/posts")
.reply(200, {});
nock(base)
.get("/users/1/avatar")
.reply(200, {});
nock(base)
.get("/users/1/cover")
.reply(200, {});
nock(base)
.put("/users/me", { locale: "de_DE", timezone: "Europe/Berlin" })
.reply(200, {});
nock(base)
.patch("/users/me", { name: "pnut-butter user" })
.reply(200, {});
nock(base)
.get("/users/1/following")
.reply(200, {});
nock(base)
.get("/users/1/followers")
.reply(200, {});
nock(base)
.put("/users/2/follow")
.reply(200, {});
nock(base)
.delete("/users/2/follow")
.reply(200, {});
nock(base)
.get("/users/me/muted")
.reply(200, {});
nock(base)
.put("/users/2/mute")
.reply(200, {});
nock(base)
.delete("/users/2/mute")
.reply(200, {});
nock(base)
.get("/users/me/blocked")
.reply(200, {});
nock(base)
.put("/users/2/block")
.reply(200, {});
nock(base)
.delete("/users/2/block")
.reply(200, {});
nock(base)
.get("/presence")
.reply(200, {});
nock(base)
.get("/presence/2")
.reply(200, {});
nock(base)
.put("/users/me/presence")
.reply(200, {});
nock(base)
.put("/users/me/presence", { presence: "A presence message" })
.reply(200, {});
nock(base)
.get("/users/search?q=news&types=feed")
.reply(200, {});
});
after(function() {
nock.cleanAll();
});
describe("User endpoints", () => {
it("should be able to fetch a user by id", () => {
return pnut.user(1).should.become({});
});
it("should be able to fetch users by their ids", () => {
return pnut.users(4, 12, 1000).should.become({});
});
it("should be able to fetch a users avatar", () => {
expect(pnut.avatar(1)).to.be.fulfilled;
});
it("should be able to upload a new avatar image");
it("should be able to fetch a users cover", () => {
expect(pnut.cover("1")).to.be.fulfilled;
});
it("should be able to upload a new cover image");
it("should be able to update the profile with a single object", () => {
return pnut
.replaceProfile({
locale: "de_DE",
timezone: "Europe/Berlin"
})
.should.become({});
});
it("should be able to update only given parts of the profile", () => {
return pnut
.updateProfile({
name: "pnut-butter user"
})
.should.become({});
});
it("should be able to retrieve a list of people a user follows", () => {
return pnut.following(1).should.become({});
});
it("should be able to retrieve a list of people a user is following", () => {
return pnut.followers(1).should.become({});
});
it("should be able to follow another user", () => {
return pnut.follow(2).should.become({});
});
it("should be able to unfollow a user", () => {
return pnut.unfollow(2).should.become({});
});
it("should be able to get a list of muted users", () => {
return pnut.muted().should.become({});
});
it("should be able to mute a user", () => {
return pnut.mute(2).should.become({});
});
it("should be able to unmute a user", () => {
return pnut.unmute(2).should.become({});
});
it("should be able to get a list of blocked users", () => {
return pnut.blocked(2).should.become({});
});
it("should be able to block a user", () => {
return pnut.block(2).should.become({});
});
it("should be able to unblock a user", () => {
return pnut.unblock(2).should.become({});
});
it("should be able to get presence information for all users", () => {
return pnut.presence().should.become({});
});
it("should be able to get presence information of another user", () => {
return pnut.presenceOf(2).should.become({});
});
it("should be able to update presence", () => {
return pnut.updatePresence().should.become({});
});
it("should be able to update presence with an optional message", () => {
return pnut.updatePresence("A presence message").should.become({});
});
it("should be possible to search for users", () => {
return pnut.searchUsers({ q: "news", types: "feed" });
});
});