forked from kaiwood/pnut-butter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessages_test.js
137 lines (107 loc) · 3.25 KB
/
messages_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
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("/somewhere")
.reply(200, {});
nock(base)
.get("/channels/1/messages/1")
.reply(200, {});
nock(base)
.get("/channels/1/messages/1/thread")
.reply(200, {});
nock(base)
.get("/channels/messages?ids=1,2,3")
.reply(200, {});
nock(base)
.get("/channels/1/messages")
.reply(200, {});
nock(base)
.get("/users/me/messages")
.reply(200, {});
nock(base)
.post("/channels/1/messages", {
text: "An important message"
})
.reply(200, {});
nock(base)
.delete("/channels/1/messages/1")
.reply(200, {});
nock(base)
.get("/channels/1/sticky_messages")
.reply(200, {});
nock(base)
.put("/channels/1/messages/1/sticky")
.reply(200, {});
nock(base)
.delete("/channels/1/messages/1/sticky")
.reply(200, {});
nock(base)
.post("/channels/pm/messages", {
destinations: ["@kwood"],
text: "A new PM to a single user"
})
.reply(200, {});
nock(base)
.post("/channels/pm/messages", {
destinations: [1, 5, "@kwood"],
text: "A new PM to multiple users"
})
.reply(200, {});
nock(base)
.get("/channels/messages/search?channel_ids=600,18")
.reply(200, {});
});
after(function() {
nock.cleanAll();
});
describe("Messages", () => {
it("should be able to retrieve a message from a channel", () => {
return pnut.message(1, 1).should.become({});
});
it("should be able to retrieve a thread of messages", () => {
return pnut.messageThread(1, 1).should.become({});
});
it("should be able to find specified message", () => {
return pnut.messages(1, 2, 3).should.become({});
});
it("should be able to retrieve messages from a channel", () => {
return pnut.channelMessages(1).should.become({});
});
it("should be able to retrieve a list of the authenticated users messages (pnut.usersMessages)", () => {
return pnut.personalMessages().should.become({});
});
it("should be able to send a message", () => {
return pnut.createMessage(1, "An important message").should.become({});
});
it("should be able to delete a message", () => {
return pnut.deleteMessage(1, 1).should.become({});
});
it("should be able to retrieve a list of sticky messages (pnut.stickies)", () => {
return pnut.stickies(1).should.become({});
});
it("should be able to create a sticky", () => {
return pnut.sticky(1, 1).should.become({});
});
it("should be able to delete a sticky", () => {
return pnut.unsticky(1, 1).should.become({});
});
it("should be able to send a private message to a user", () => {
return pnut
.sendMessage("@kwood", "A new PM to a single user")
.should.become({});
});
it("should be able to send private messages to multiple users", () => {
return pnut
.sendMessage([1, 5, "@kwood"], "A new PM to multiple users")
.should.become({});
});
it("should be possible to search for messages", () => {
return pnut.searchMessages({ channelIds: [600, 18] }).should.become({});
});
});