47 lines
2.2 KiB
JavaScript
47 lines
2.2 KiB
JavaScript
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
const clientBase_1 = require("../clients/clientBase");
|
|
const channelManager_1 = require("../channelManager");
|
|
var expect = require('chai').expect;
|
|
var sinon = require('sinon');
|
|
var name = 'test channel';
|
|
var data = { 'client': 'test', 'client_type': 'site', 'user_id': 125, 'user_type': 'user', 'channel': name };
|
|
var WebSocketClient = require('websocket').client;
|
|
var wsClient = new WebSocketClient();
|
|
var client = new clientBase_1.default(data, wsClient);
|
|
let channelManager = new channelManager_1.default();
|
|
describe('ChannelManager', function () {
|
|
var channel;
|
|
it('should create a channel', function () {
|
|
channel = channelManager.createChannel(data);
|
|
expect(channel.id).to.be.equal(name);
|
|
});
|
|
it('should return existing channel when attempting to create a channel', function () {
|
|
channel = channelManager.createChannel(data);
|
|
expect(channel.id).to.be.equal(name);
|
|
});
|
|
it('should return a channel when searching if channel exists', function () {
|
|
var exists = channelManager.channelExists(channel.id);
|
|
var result = exists ? true : false;
|
|
expect(result).to.be.equal(true);
|
|
});
|
|
it('should not return a channel when serachingif channel exists', function () {
|
|
var exists = channelManager.channelExists('no channel');
|
|
var result = exists ? true : false;
|
|
expect(result).to.be.equal(false);
|
|
});
|
|
it('should add a client to channel', function () {
|
|
var result = channelManager.addClientToChannel(client, channel.id);
|
|
expect(result.status).to.be.equal('success');
|
|
});
|
|
it('should not add a client to channel', function () {
|
|
var result = channelManager.addClientToChannel(client, 'no channel');
|
|
expect(result.status).to.be.equal('notice');
|
|
});
|
|
it('should create a channel of type MHSChannel', function () {
|
|
var data2 = { 'channel': 'test channel 2', 'client': 'mhs', 'client_type': 'site' };
|
|
var result = channelManager.createByChannelType(data2);
|
|
expect(result.id).to.be.equal('test channel 2');
|
|
});
|
|
});
|
|
//# sourceMappingURL=channelManager.spec.js.map
|