forked from kaiwood/pnut-butter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp_streams_test.js
71 lines (59 loc) · 1.79 KB
/
app_streams_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
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("/streams").reply(200, {});
nock(base).get("/streams/post").reply(200, {});
nock(base)
.post("/streams", {
type: "long_poll",
object_types: ["post", "message", "channel_subscription", "bookmark"],
key: "jelly"
})
.reply(200, {});
nock(base)
.put("/streams", {
object_types: ["post", "message"],
key: "jelly"
})
.reply(200, {});
nock(base).delete("/streams").reply(200, {});
nock(base).delete("/streams/jelly").reply(200, {});
});
after(function() {
nock.cleanAll();
});
describe("App Streams", () => {
it("should be able to get all app streams for the authenticated app", () => {
return pnut.streams().should.become({});
});
it("should be able to get a specific app stream by its key", () => {
return pnut.stream("post").should.become({});
});
it("should be able to create an app stream for the authenticated app", () => {
return pnut
.createStream({
objectTypes: ["post", "message", "channel_subscription", "bookmark"],
key: "jelly"
})
.should.become({});
});
it("should be able to update an app stream", () => {
return pnut
.updateStream({
objectTypes: ["post", "message"],
key: "jelly"
})
.should.become({});
});
it("should be able to delete all app streams for the authorized app", () => {
return pnut.deleteStreams().should.become({});
});
it("should be able to delete a specific app stream by its key", () => {
return pnut.deleteStream("jelly").should.become({});
});
});