/**
 * Tests DelayEventHandler
 *
 *  Copyright (C) 2010-2019 R-T Specialty, LLC.
 *
 *  This file is part of the Liza Data Collection Framework.
 *
 *  liza is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var chai_1 = require("chai");
var DelegateEventHandler_1 = require("../../../src/client/event/DelegateEventHandler");
var UnknownEventError_1 = require("../../../src/client/event/UnknownEventError");
describe('DelegateEventHandler', function () {
    it('Calls a handler', function (done) {
        var handle_called = false;
        var handlers = {
            rate: {
                handle: function (_, __, ___) {
                    handle_called = true;
                },
            },
        };
        var sut = new DelegateEventHandler_1.DelegateEventHandler(handlers);
        sut.handle('rate', function () { }, {});
        chai_1.expect(handle_called).to.equal(true);
        done();
    });
    it('Throws exception if no handler is found for an event type', function (done) {
        var handle_called = false;
        var handlers = {
            rate: {
                handle: function (_, __, ___) {
                    handle_called = true;
                },
            },
        };
        var sut = new DelegateEventHandler_1.DelegateEventHandler(handlers);
        chai_1.expect(function () {
            sut.handle('delay', function () { }, {});
        }).to.throw(UnknownEventError_1.UnknownEventError);
        chai_1.expect(handle_called).to.equal(false);
        done();
    });
    it('Returns true if it has a handler for an event type', function (done) {
        var handlers = {
            rate: {
                handle: function (_, __, ___) { },
            },
        };
        var sut = new DelegateEventHandler_1.DelegateEventHandler(handlers);
        chai_1.expect(sut.hasHandler('rate')).to.equal(true);
        done();
    });
    it("Returns false if it doesn't have a handler for an event type", function (done) {
        var handlers = {
            rate: {
                handle: function (_, __, ___) { },
            },
        };
        var sut = new DelegateEventHandler_1.DelegateEventHandler(handlers);
        chai_1.expect(sut.hasHandler('delay')).to.equal(false);
        done();
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiRGVsZWdhdGVFdmVudEhhbmRsZXJUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiRGVsZWdhdGVFdmVudEhhbmRsZXJUZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBbUJHO0FBRUgsWUFBWSxDQUFDOztBQUViLDZCQUE0QjtBQUM1Qix1RkFBMkY7QUFLM0YsaUZBQThFO0FBRTlFLFFBQVEsQ0FBQyxzQkFBc0IsRUFBRTtJQUMvQixFQUFFLENBQUMsaUJBQWlCLEVBQUUsVUFBQSxJQUFJO1FBQ3hCLElBQUksYUFBYSxHQUFHLEtBQUssQ0FBQztRQUUxQixJQUFNLFFBQVEsR0FBa0I7WUFDOUIsSUFBSSxFQUFnQjtnQkFDbEIsTUFBTSxFQUFFLFVBQUMsQ0FBTSxFQUFFLEVBQU8sRUFBRSxHQUFRO29CQUNoQyxhQUFhLEdBQUcsSUFBSSxDQUFDO2dCQUN2QixDQUFDO2FBQ0Y7U0FDRixDQUFDO1FBRUYsSUFBTSxHQUFHLEdBQUcsSUFBSSwyQ0FBRyxDQUFDLFFBQVEsQ0FBQyxDQUFDO1FBRTlCLEdBQUcsQ0FBQyxNQUFNLENBQUMsTUFBTSxFQUFFLGNBQU8sQ0FBQyxFQUFFLEVBQUUsQ0FBQyxDQUFDO1FBRWpDLGFBQU0sQ0FBQyxhQUFhLENBQUMsQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ3JDLElBQUksRUFBRSxDQUFDO0lBQ1QsQ0FBQyxDQUFDLENBQUM7SUFFSCxFQUFFLENBQUMsMkRBQTJELEVBQUUsVUFBQSxJQUFJO1FBQ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