{"size": 4028, "ext": "js", "max_stars_repo_path": "tests/reset.js", "max_stars_repo_name": "objectliteral/multivents", "max_stars_repo_stars_event_min_datetime": "2017-02-14T23:13:46.000Z", "max_stars_repo_stars_event_max_datetime": "2017-03-01T23:05:48.000Z", "max_issues_repo_path": "tests/reset.js", "max_issues_repo_name": "objectliteral/multivents", "max_issues_repo_issues_event_min_datetime": "2017-03-06T16:24:57.000Z", "max_issues_repo_issues_event_max_datetime": "2018-09-25T17:08:30.000Z", "max_forks_repo_path": "tests/reset.js", "max_forks_repo_name": "objectliteral/multivents", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": 9, "max_forks_count": null, "avg_line_length": 31.2248062016, "max_line_length": 111, "alphanum_fraction": 0.6119662363}
var assert = require('assert'),
    Channel = require('../dist/multivents.umd.js');

describe('`reset` function',  function () {
  
  it('should not throw any exceptions when called with no arguments', function () {
    var channel = Channel();
    try {
        channel.reset();
    } catch (e) {
        assert.fail(undefined, e, e.toString());
    }
  });

  it('should not throw any exceptions when called with the name of an event that does not exist', function () {
    var channel = Channel();
    try {
        channel.reset('ping');
    } catch (e) {
        assert.fail(undefined, e, e.toString());
    }
  });

  it('should return the channel it was called on when called with no arguments', function () {
    var channel = Channel();
    assert.equal(channel, channel.reset());
  });

  it('should return the channel it was called on when called with an event type', function () {
    var channel = Channel();
    assert.equal(channel, channel.reset('ping'));
  });

  it('should remove all callbacks from the channel if called with no arguments', function () {
    var channel = Channel({});
    channel.on('ping', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.reset();
    channel.emit('ping');
  });

  it('should remove all callbacks from a specific event if called with the event type', function () {
    var channel = Channel({});
    channel.on('ping', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.on('pong', function () {
      assert(true);
    });
    channel.reset('ping');
    channel.emit('ping');
    channel.emit('pong');
  });

  it('should unlock a locked channel if called with no arguments', function () {
    var channel = Channel();
    channel.lock();
    channel.on('ping', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.emit('ping');
    channel.reset();
    channel.on('ping', function () {
      assert(true);
    });
    channel.emit('ping');
  });

  it('should unsilence a silenced channel if called with no arguments', function () {
    var channel = Channel();
    channel.on('ping', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.silence();
    channel.reset();
    channel.on('ping', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.emit('ping');
  });

  it('should unlock a locked event if called with the event name', function () {
    var channel = Channel();
    channel.lock('ping');
    channel.lock('pong');
    channel.on('ping', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.on('pong', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.emit('ping');
    channel.emit('pong');
    channel.reset('ping');
    channel.on('ping', function () {
      assert(true);
    });
    channel.on('pong', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.emit('pong');
    channel.emit('ping');
  });

  it('should unsilence a silenced event if called with the event name', function () {
    var channel = Channel();
    channel.on('ping', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.on('pong', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.silence('ping');
    channel.silence('pong');
    channel.emit('ping');
    channel.emit('pong');
    channel.reset('ping');
    channel.on('ping', function () {
      assert(true);
    });
    channel.on('pong', function () {
      assert.fail(undefined, undefined, 'This function must not be executed.');
    });
    channel.emit('pong')
    channel.emit('ping');
  });

});