/**
 * Tests NavFreezeEventHandler
 *
 *  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 NavFreezeEventHandler_1 = require("../../../src/client/event/NavFreezeEventHandler");
describe('NavFreezeEventHandler', function () {
    it('Calls callback', function () {
        var client = getMockClient();
        var sut = new NavFreezeEventHandler_1.NavFreezeEventHandler(client);
        var data = {
            action: 'navFreeze',
        };
        var callback_called = false;
        var cb = function () {
            callback_called = true;
        };
        sut.handle('navFreeze', cb, data);
        chai_1.expect(callback_called).to.equal(true);
    });
    [
        {
            label: 'Use default lock message if none is supplied',
            value: '',
            expected: '<div class="text">Navigation is locked</div>',
        },
        {
            label: 'Use lock message if one is supplied',
            value: 'Foobar',
            expected: '<div class="text">Foobar</div>',
        },
    ].forEach(function (_a) {
        var label = _a.label, value = _a.value, expected = _a.expected;
        it(label, function (done) {
            var ui = getMockUi();
            var client = getMockClient(ui);
            var sut = new NavFreezeEventHandler_1.NavFreezeEventHandler(client);
            var data = {
                action: 'navFreeze',
                value: value,
            };
            ui.showNotifyBar = function (given) {
                chai_1.expect(given.innerHTML).to.equal(expected);
                done();
                return ui;
            };
            sut.handle('navFreeze', function () { }, data);
        });
    });
});
function getMockUi() {
    var ui = {
        showNotifyBar: function () { return ui; },
        freezeNav: function () { return ui; },
    };
    return ui;
}
function getMockDocument() {
    var element = getMockElement();
    return {
        createElement: function () { return element; },
    };
}
function getMockElement() {
    return {
        innerHTML: '',
    };
}
function getMockQuote() {
    return {
        isLocked: function () { return false; },
    };
}
function getMockClient(ui) {
    var document = getMockDocument();
    var quote = getMockQuote();
    return {
        getUi: function () { return ui || getMockUi(); },
        getDocument: function () { return document; },
        getQuote: function () { return quote; },
    };
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTmF2RnJlZXplRXZlbnRIYW5kbGVyVGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIk5hdkZyZWV6ZUV2ZW50SGFuZGxlclRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FtQkc7QUFFSCxZQUFZLENBQUM7O0FBRWIsNkJBQTRCO0FBSTVCLHlGQUE2RjtBQUc3RixRQUFRLENBQUMsdUJBQXVCLEVBQUU7SUFDaEMsRUFBRSxDQUFDLGdCQUFnQixFQUFFO1FBQ25CLElBQU0sTUFBTSxHQUFHLGFBQWEsRUFBRSxDQUFDO1FBQy9CLElBQU0sR0FBRyxHQUFHLElBQUksNkNBQUcsQ0FBQyxNQUFNLENBQUMsQ0FBQztRQUM1QixJQUFNLElBQUksR0FBaUI7WUFDekIsTUFBTSxFQUFFLFdBQVc7U0FDcEIsQ0FBQztRQUVGLElBQUksZUFBZSxHQUFHLEtBQUssQ0FBQztRQUU1QixJQUFNLEVBQUUsR0FBRztZQUNULGVBQWUsR0FBRyxJQUFJLENBQUM7UUFDekIsQ0FBQyxDQUFDO1FBRUYsR0FBRyxDQUFDLE1BQU0sQ0FBQyxXQUFXLEVBQUUsRUFBRSxFQUFFLElBQUksQ0FBQyxDQUFDO1FBRWxDLGFBQU0sQ0FBQyxlQUFlLENBQUMsQ0FBQyxFQUFFLENBQUMsS0FBSyxDQUFDLElBQUksQ0FBQyxDQUFDO0lBQ3pDLENBQUMsQ0FBQyxDQUFDO0lB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