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
|
import consumerTest from "../test_helpers/consumer_test_helper"
const {module} = QUnit
module("ActionCable.Subscriptions", () => {
consumerTest("create subscription with channel string", ({consumer, server, assert, done}) => {
const channel = "chat"
server.on("message", (message) => {
const data = JSON.parse(message)
assert.equal(data.command, "subscribe")
assert.equal(data.identifier, JSON.stringify({channel}))
done()
})
consumer.subscriptions.create(channel)
})
consumerTest("create subscription with channel object", ({consumer, server, assert, done}) => {
const channel = {channel: "chat", room: "action"}
server.on("message", (message) => {
const data = JSON.parse(message)
assert.equal(data.command, "subscribe")
assert.equal(data.identifier, JSON.stringify(channel))
done()
})
consumer.subscriptions.create(channel)
})
})
|