added unit testing, and started implementing unit tests...phew

This commit is contained in:
Josh Burman
2019-03-12 22:28:02 -04:00
parent 74aad4a957
commit e8c2539f1b
3489 changed files with 464813 additions and 88 deletions

View File

@ -1,19 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var logger = require('../logger');
class ChannelBase {
constructor(id) {
this.clients = [];
this.id = id;
console.log('channel created');
logger.accessLog.info('Channel Created', { channelId: id });
}
addClient(client) {
console.log(client.data);
if (this.clientExists(client.id)) {
console.log('client already exits in channel');
logger.errorLog.info('Client already exits in channel', { channelId: this.id, clientId: client.id });
return { 'status': 'notice', 'message': 'client aleady exists in channel' };
}
else {
this.clients.push(client);
console.log('added client to channel');
logger.accessLog.info('Added client to channel', { channelId: this.id, clientId: client.id });
return { 'status': 'success', 'message': 'client added' };
}
}
clientExists(id) {
@ -28,13 +30,13 @@ class ChannelBase {
for (let client of this.clients) {
if (client != from) {
client.ws.send(message);
console.log(`sent to ${client.id}: %s`, message);
console.log(message);
logger.accessLog.info(`sent to ${client.id}: `, { message: message });
}
else {
console.log('client is same as sender');
logger.accessLog.info(`client is same as sender: ${client.id} - `, { message: message });
}
}
return { 'status': 'success', 'message': `message broadcast complete` };
}
}
;