<commit_before>var test = require('tape');
var ift = require('../library/ift');
var config = {
  IFT_ORIGIN: location.origin,
  IFT_PATH: location.pathname + '?remote'
};

module.exports = function() {

  test("Events.", function(t) {
    t.plan(2);
    var obj = {}, cb;
    ift.util.mixin(obj, ift.Events);
    obj.on('test', cb = function() {
      t.pass('"test" event fired.');
    });
    obj.trigger('test');
    obj.trigger('test');
    obj.off('test');
    obj.trigger('test');
    obj.on('test', cb);
    obj.off();
    obj.trigger('test');
    t.end();
  });

  test("Transport correctly defines role.", function(t) {
    t.plan(2);

    var local, remote;

    local = ift.connect({
      remoteOrigin: config.IFT_ORIGIN,
      remotePath: config.IFT_PATH
    });
    t.equal(local.role, 'local');
    local.destroy();

    remote = ift.connect({
      trustedOrigins: [config.IFT_ORIGIN]
    });
    t.equal(remote.role, 'remote');
    remote.destroy();

    t.end();
  });

  test("Invoke and callback.", function(t) {
    t.plan(1);

    var transport = ift.connect({
      remoteOrigin: config.IFT_ORIGIN,
      remotePath: config.IFT_PATH,
    }).on('ift:connect', function() {
      var client = transport.client('test');
      client.send('invoke', 'test', [], function() {
        t.pass('Acknowledged.');
        transport.destroy();
        t.end();
      });
    });
  });

  test("Trigger.", function(t) {
    t.plan(1);

    var transport, client;

    ift.define(ift.roles.LOCAL, 'test', function(__super__) {
      return {
        ack: function() {
          t.pass('Acknowledged.');
          transport.destroy();
          t.end();
        }
      };
    });

    transport = ift.connect({
      remoteOrigin: config.IFT_ORIGIN,
      remotePath: config.IFT_PATH
    }).on('ift:connect', function() {
      client = transport.client('test');
      client.send('trigger', 'test', []);
    });
  });

};
<commit_msg>Snip comma<commit_after>var test = require('tape');
var ift = require('../library/ift');
var config = {
  IFT_ORIGIN: location.origin,
  IFT_PATH: location.pathname + '?remote'
};

module.exports = function() {

  test("Events.", function(t) {
    t.plan(2);
    var obj = {}, cb;
    ift.util.mixin(obj, ift.Events);
    obj.on('test', cb = function() {
      t.pass('"test" event fired.');
    });
    obj.trigger('test');
    obj.trigger('test');
    obj.off('test');
    obj.trigger('test');
    obj.on('test', cb);
    obj.off();
    obj.trigger('test');
    t.end();
  });

  test("Transport correctly defines role.", function(t) {
    t.plan(2);

    var local, remote;

    local = ift.connect({
      remoteOrigin: config.IFT_ORIGIN,
      remotePath: config.IFT_PATH
    });
    t.equal(local.role, 'local');
    local.destroy();

    remote = ift.connect({
      trustedOrigins: [config.IFT_ORIGIN]
    });
    t.equal(remote.role, 'remote');
    remote.destroy();

    t.end();
  });

  test("Invoke and callback.", function(t) {
    t.plan(1);

    var transport = ift.connect({
      remoteOrigin: config.IFT_ORIGIN,
      remotePath: config.IFT_PATH
    }).on('ift:connect', function() {
      var client = transport.client('test');
      client.send('invoke', 'test', [], function() {
        t.pass('Acknowledged.');
        transport.destroy();
        t.end();
      });
    });
  });

  test("Trigger.", function(t) {
    t.plan(1);

    var transport, client;

    ift.define(ift.roles.LOCAL, 'test', function(__super__) {
      return {
        ack: function() {
          t.pass('Acknowledged.');
          transport.destroy();
          t.end();
        }
      };
    });

    transport = ift.connect({
      remoteOrigin: config.IFT_ORIGIN,
      remotePath: config.IFT_PATH
    }).on('ift:connect', function() {
      client = transport.client('test');
      client.send('trigger', 'test', []);
    });
  });

};

{'fraction_non_alphanumeric': 0.1923274974253347, 'fraction_numerical': 0.0020597322348094747, 'mean_word_length': 2.487432675044883, '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': '4350719', 'n_tokens_mistral': 1313, 'n_tokens_neox': 1277, 'n_words': 229}