"use strict";
/**
 * Test case for TabbedGroupUi
 *
 *  Copyright (C) 2010-2020 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 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 General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
Object.defineProperty(exports, "__esModule", { value: true });
var expect = require('chai').expect, sinon = require('sinon');
var TabbedGroupUi_1 = require("../../../src/ui/group/TabbedGroupUi");
var CommonResources_1 = require("./CommonResources");
describe('ui.group.TabbedGroupUi', function () {
    describe('#hideAddRemove', function () {
        [
            {
                label: 'value is true, hide add button',
                tab_count: 3,
                max_rows: 3,
                value: true,
                add_tab_hide_expected: true,
                add_tab_show_expected: false,
                icon_close_hide_expected: true,
                icon_close_show_expected: false,
            },
            {
                label: 'value is false, show add button when tab count is less than max count',
                tab_count: 2,
                max_rows: 3,
                value: false,
                add_tab_hide_expected: false,
                add_tab_show_expected: true,
                icon_close_hide_expected: false,
                icon_close_show_expected: true,
            },
            {
                label: 'value is false, show add button when max is 0',
                tab_count: 2,
                max_rows: 0,
                value: false,
                add_tab_hide_expected: false,
                add_tab_show_expected: true,
                icon_close_hide_expected: false,
                icon_close_show_expected: true,
            },
            {
                label: 'value is false, do not show button when max is equal to tab count',
                tab_count: 3,
                max_rows: 3,
                value: false,
                add_tab_hide_expected: false,
                add_tab_show_expected: false,
                icon_close_hide_expected: false,
                icon_close_show_expected: true,
            },
        ].forEach(function (_a) {
            var label = _a.label, tab_count = _a.tab_count, max_rows = _a.max_rows, value = _a.value, add_tab_hide_expected = _a.add_tab_hide_expected, add_tab_show_expected = _a.add_tab_show_expected, icon_close_hide_expected = _a.icon_close_hide_expected, icon_close_show_expected = _a.icon_close_show_expected;
            it(label, function () {
                var add_tab_hide_called = false;
                var add_tab_show_called = false;
                var icon_close_hide_called = false;
                var icon_close_show_called = false;
                var addTab = {
                    click: sinon.stub(),
                    hide: function () {
                        add_tab_hide_called = true;
                        return;
                    },
                    show: function () {
                        add_tab_show_called = true;
                        return;
                    },
                };
                var icon_close = {
                    hide: function () {
                        icon_close_hide_called = true;
                        return;
                    },
                    show: function () {
                        icon_close_show_called = true;
                        return;
                    },
                };
                var groupTabs = {
                    append: sinon.stub(),
                    tabs: sinon.stub().returns(tab_count),
                    find: sinon.stub(),
                };
                var remove = sinon.stub().returns({
                    find: sinon.stub().returns({ text: sinon.stub() }),
                });
                groupTabs.find.withArgs('.ui-icon-close').returns(icon_close);
                groupTabs.find.withArgs('li:first').returns({ remove: remove });
                groupTabs.find.withArgs('div:first').returns({ detach: sinon.stub() });
                var $content = CommonResources_1.createJqueryContent();
                $content.find.withArgs('.groupTabs').returns(groupTabs);
                $content.find.withArgs('.action').returns({ live: sinon.stub() });
                $content.find
                    .withArgs('div.groupTabs')
                    .returns({ hasClass: sinon.stub() });
                $content.find.withArgs('.addTab:first').returns(addTab);
                var group = CommonResources_1.createGroup('foo', [], [], false, '', max_rows);
                var sut = CommonResources_1.createSut(TabbedGroupUi_1.TabbedGroupUi, {
                    $content: $content,
                    group: group,
                });
                var quote = CommonResources_1.createQuote();
                sut.init(quote);
                sut.hideAddRemove(value);
                expect(add_tab_hide_called).to.equal(add_tab_hide_expected);
                expect(add_tab_show_called).to.equal(add_tab_show_expected);
                expect(icon_close_hide_called).to.equal(icon_close_hide_expected);
                expect(icon_close_show_called).to.equal(icon_close_show_expected);
            });
        });
    });
});
//# sourceMappingURL=data:application/json;base64, 