<commit_before>/*global trajan,trajangw,expect,listen*/

describe('client', function() {
  it('should receive actions', function(done) {
    var server = listen(function(port) {
      var gateway = trajangw();
      gateway.addService('test', 'localhost:' + port);
      var route = gateway.route('test', 'test', 'test');
      server.on('connection', function(client, gameId) {
        route.send('myaction');
        client.on('action', function(str) {
          expect(str).to.equal('myaction');
          done();
        });
      });
    });
  });
  it('should receive disconnect', function(done) {
    var server = listen(function(port) {
      var gateway = trajangw();
      gateway.addService('test', 'localhost:' + port);
      var route = gateway.route('test', 'test', 'test');
      server.on('connection', function(client, gameId) {
        route.disconnect();
        client.on('disconnect', function() {
          done();
        });
      });
    });
  });
});<commit_msg>Update tests<commit_after>/*global trajan,trajangw,expect,listen*/

function connect(serviceId, gameId, clientId, callback) {
  var server = listen(function(port) {
    var gateway = trajangw();
    gateway.addService(serviceId, 'localhost:' + port);
    var route = gateway.route(serviceId, gameId, clientId);
    if (callback) callback(route);
  });
  return server;
}

describe('client', function() {
  it('should have an id', function(done) {
    var server = connect('myservice', 'mygame', 'myclient');
    server.on('connection', function(client, gameId) {
      expect(client.id).to.equal('myclient');
      done();
    });
  });
  it('should receive actions', function(done) {
    var server = connect('s', 'g', 'c', function(route) {
      server.on('connection', function(client, gameId) {
        route.send('myaction');
        client.on('action', function(str) {
          expect(str).to.equal('myaction');
          done();
        });
      });
    });
  });
  it('should receive disconnect', function(done) {
    var server = connect('s', 'g', 'c', function(route) {
      server.on('connection', function(client, gameId) {
        route.disconnect();
        client.on('disconnect', function() {
          done();
        });
      });
    });
  });
});
{'fraction_non_alphanumeric': 0.18423383525243578, 'fraction_numerical': 0.0, 'mean_word_length': 3.0124333925399647, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '568106', 'n_tokens_mistral': 685, 'n_tokens_neox': 672, 'n_words': 134}