forked from kaiwood/pnut-butter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchannels_test.js
148 lines (114 loc) · 3.5 KB
/
channels_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
const chai = require("chai");
const chaiAsPromised = require("chai-as-promised");
const nock = require("nock");
chai.use(chaiAsPromised);
chai.should();
const pnut = require("../lib/pnut");
before(function() {
let base = "https://api.pnut.io/v0";
nock(base)
.get("/channels/1")
.reply(200, {});
nock(base)
.get("/channels?ids=1,2,3")
.reply(200, {});
nock(base)
.get("/users/me/channels")
.reply(200, {});
nock(base)
.get("/users/me/channels/existing_pm?ids=1,2")
.reply(200, {});
nock(base)
.get("/users/me/channels/num_unread/pm")
.reply(200, {});
nock(base)
.delete("/users/me/channels/num_unread/pm")
.reply(200, {});
nock(base)
.delete("/channels/1")
.reply(200, {});
nock(base)
.get("/users/me/channels/subscribed")
.reply(200, {});
nock(base)
.get("/channels/1/subscribers")
.reply(200, {});
nock(base)
.put("/channels/1/subscribe")
.reply(200, {});
nock(base)
.delete("/channels/1/subscribe")
.reply(200, {});
nock(base)
.get("/users/me/channels/muted")
.reply(200, {});
nock(base)
.put("/channels/1/mute")
.reply(200, {});
nock(base)
.delete("/channels/1/mute")
.reply(200, {});
nock(base)
.get(
"/channels/search?is_public=1&channel_types=io.pnut.core.chat&categories=fun"
)
.reply(200, {});
});
after(function() {
nock.cleanAll();
});
describe("Channels", () => {
it("should be able to fetch a single channel", () => {
return pnut.channel(1).should.become({});
});
it("should be able to fetch multiple channels", () => {
return pnut.channels(1, 2, 3).should.become({});
});
it("should be able to fetch channels created by the authenticated user", () => {
return pnut.usersChannels().should.become({});
});
it("should be able to retrieve a private message channel for a set of users", () => {
return pnut.pmChannelFor(1, 2).should.become({});
});
it("should be able to retrive to number of unread private messages", () => {
return pnut.unread().should.become({});
});
it("should be able to mark all private messages as read", () => {
return pnut.markAllAsRead().should.become({});
});
it("should be able to create a channel (pnut.createChannel)");
it("should be able to update a channel (pnut.updateChannel");
it("should be able to deactivate a channel", () => {
return pnut.deactivateChannel(1).should.become({});
});
it("should be able to retrieve a list of subscribed channels", () => {
return pnut.subscribed().should.become({});
});
it("should be able to retrieve a list of subscribers of a channel", () => {
return pnut.subscribers(1).should.become({});
});
it("should be able to subscribe to a channel", () => {
return pnut.subscribe(1).should.become({});
});
it("should be able to unsubscribe from a channel", () => {
return pnut.unsubscribe(1).should.become({});
});
it("should be able to receive a list of muted channels", () => {
return pnut.mutedChannels().should.become({});
});
it("should be able to mute a channel (pnut.muteChannel)", () => {
return pnut.muteChannel(1).should.become({});
});
it("should be able to unmute a channel (pnut.unmuteChannel)", () => {
return pnut.unmuteChannel(1).should.become({});
});
it("should be possible to search for channels", () => {
return pnut
.searchChannels({
isPublic: 1,
channelTypes: "io.pnut.core.chat",
categories: "fun"
})
.should.become({});
});
});