more tests, added ability to remove clients from a channel
This commit is contained in:
@ -39,4 +39,14 @@ describe('ChannelBase', function () {
|
||||
var result = channel.broadcastMessage(client, 'test message');
|
||||
expect(result.status).to.be.equal('success');
|
||||
});
|
||||
|
||||
it('should be able to remove client from channel', function () {
|
||||
var result = channel.removeClient(client.id);
|
||||
expect(result).to.be.equal(true);
|
||||
});
|
||||
|
||||
it('should not be able to remove client that doesnn\'t exist from channel', function () {
|
||||
var result = channel.removeClient(126);
|
||||
expect(result).to.be.equal(false);
|
||||
});
|
||||
});
|
||||
|
@ -55,4 +55,19 @@ describe('ChannelManager', function () {
|
||||
var result = channelManager.createByChannelType(data2);
|
||||
expect(result.id).to.be.equal('test channel 2');
|
||||
});
|
||||
|
||||
it('should remove client from channel', function () {
|
||||
var result = channelManager.removeClientFromChannel(client.id , 'test channel');
|
||||
expect(result).to.be.equal(true);
|
||||
});
|
||||
|
||||
it('should be unable to remove a client that doesn\'t exit from channel', function () {
|
||||
var result = channelManager.removeClientFromChannel(126 , 'test channel');
|
||||
expect(result).to.be.equal(false);
|
||||
});
|
||||
|
||||
it('should be unable to remove a client from a channel that doesn\'t exist', function () {
|
||||
var result = channelManager.removeClientFromChannel(client.id , 'test channel 3');
|
||||
expect(result).to.be.equal(false);
|
||||
});
|
||||
});
|
||||
|
@ -0,0 +1,29 @@
|
||||
import * as WebSocket from 'ws';
|
||||
import ClientBase from '../clients/clientBase';
|
||||
|
||||
var expect = require('chai').expect;
|
||||
var assert = require('chai').assert;
|
||||
var sinon = require('sinon');
|
||||
|
||||
var name: string = 'test channel';
|
||||
var data: any = { 'client': 'test', 'client_type':'site', 'user_id': 125, 'user_type': 'user', 'channel': name }
|
||||
var WebSocketClient = require('websocket').client;
|
||||
var wsClient = new WebSocketClient();
|
||||
var client: ClientBase = new ClientBase(data, wsClient);
|
||||
|
||||
describe('ClientBase', function () {
|
||||
it('should get client data', function () {
|
||||
var result = client.getData();
|
||||
expect(result.user_id).to.be.equal(125);
|
||||
});
|
||||
|
||||
it('should get client type', function () {
|
||||
var result = client.clientType();
|
||||
expect(result).to.be.equal('test');
|
||||
});
|
||||
|
||||
it('should get client object type', function () {
|
||||
var result = client.type();
|
||||
expect(result).to.be.equal('site');
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user