<commit_before>var io = require('socket.io-client');
var app = require('../server/server.js');
var expect = require('chai').expect;
var socketURL = 'http://localhost:4568/ngage';

var options ={
  transports: ['websocket'],
  'force new connection': true,
  'path': '/sockets'
};

describe("Chat Server",function(){
  var server;
  var client1, client2;

  before(function() {
    server = app.listen(4568, function() {
      console.log('Server is listening on 4568');
    });
    client1 = io.connect(socketURL, options);
    client2 = io.connect(socketURL, options);
  });

  after(function() {
    server.close();
  });

  it('Should broadcast new user to all users', function(done){
    this.timeout(5000);
    client1.emit('subscribe', {room: 'channel'});
    client1.on('join', data => {
      client2.emit('subscribe', {room: 'channel'});
      client2.on('join', data => {
        client1.emit('start', {room: 'channel'});
        client2.on('start', data => {
          done();
        })
      })
    })
  });

  it('Should receive askQ socket and receive a server is unavailable message', function(done){
    this.timeout(5000);
    client1.emit('askQ', {question: {questionID:5}});
    client1.on('answers', data => {
      expect(data).to.equal('Server is unavailable');
      done();
    })
  });

  it('Should receive showA socket and receive a server is unavailable message', function(done){
    this.timeout(5000);
    client1.emit('showA', {questionID:5});
    client1.on('correct', data => {
      expect(data).to.equal('Server is unavailable to get correct answer');
      done();
    })
  });

  it('Should receive submitResponse socket and receive a server is unavailable message', function(done){
    this.timeout(5000);<commit_msg>(test) Update tests to listen for participant submit instead of join<commit_after>var io = require('socket.io-client');
var app = require('../server/server.js');
var expect = require('chai').expect;
var socketURL = 'http://localhost:4568/ngage';

var options ={
  transports: ['websocket'],
  'force new connection': true,
  'path': '/sockets'
};

describe("Chat Server",function(){
  var server;
  var client1, client2;

  before(function() {
    server = app.listen(4568, function() {
      console.log('Server is listening on 4568');
    });
    client1 = io.connect(socketURL, options);
    client2 = io.connect(socketURL, options);
  });

  after(function() {
    server.close();
  });

  it('Should broadcast new user to all users', function(done){
    this.timeout(5000);
    client1.emit('subscribe', {room: 'channel'});
    client1.on('participantSubmit', data => {
      client2.emit('subscribe', {room: 'channel'});
      client2.on('participantSubmit', data => {
        client1.emit('start', {room: 'channel'});
        client2.on('start', data => {
          done();
        })
      })
    })
  });

  it('Should receive askQ socket and receive a server is unavailable message', function(done){
    this.timeout(5000);
    client1.emit('askQ', {question: {questionID:5}});
    client1.on('answers', data => {
      expect(data).to.equal('Server is unavailable');
      done();
    })
  });

  it('Should receive showA socket and receive a server is unavailable message', function(done){
    this.timeout(5000);
    client1.emit('showA', {questionID:5});
    client1.on('correct', data => {
      expect(data).to.equal('Server is unavailable to get correct answer');
      done();
    })
  });

  it('Should receive submitResponse socket and receive a server is unavailable message', function(done){
    this.timeout(5000);
{'fraction_non_alphanumeric': 0.16921792374060673, 'fraction_numerical': 0.02449206790982466, 'mean_word_length': 3.520754716981132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4583537', 'n_tokens_mistral': 1134, 'n_tokens_neox': 1065, 'n_words': 271}