| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- import test from 'ava'
- import { Chatter, MAIN_CHANNEL } from '../src/services/chat.service.js'
-
- test('Make sure we can instantiate Chatter', async t => {
- const chatter = new Chatter()
- t.is(chatter._subscriptions.length, 1)
- t.is(chatter._subscriptions[0], MAIN_CHANNEL)
-
- const testCb = () => {
- const a = 'foo'
- return a
- }
- chatter.setOnMessage(testCb)
- t.is(chatter.listeners.message, testCb)
-
- chatter._setupAllChannels([
- { grouping_name: 'test-channel-01' },
- { grouping_name: 'test-channel-02' },
- ])
- t.is(chatter.subscriptions.length, 2)
- t.is(chatter.subscriptions[0], 'test-channel-01')
- t.is(chatter.subscriptions[1], 'test-channel-02')
-
- chatter.stop()
- t.is(chatter._subscriptions[0], MAIN_CHANNEL)
- })
-
- test('Use PubNub via Chatter', async t => {
- const chatter = new Chatter()
- t.is(chatter._subscriptions.length, 1)
- t.is(chatter._subscriptions[0], MAIN_CHANNEL)
-
- const testUUID = 'test_123_uuid'
- const subs = await chatter.setup(testUUID, [], {
- publishKey: 'foo',
- subscribeKey: 'bar',
- })
- t.is(chatter.uuid, testUUID)
- t.deepEqual(subs, [])
- })
|