"use strict";
/**
 * Test case for TableGroupUi
 *
 *  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 TableGroupUi_1 = require("../../../src/ui/group/TableGroupUi");
var CommonResources_1 = require("./CommonResources");
describe('ui.group.TableGroupUi', function () {
    describe('#hideAddRemove', function () {
        [
            {
                label: 'value is true, hide add button',
                row_count: 3,
                max_rows: 3,
                value: true,
                add_row_hide_expected: true,
                add_row_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',
                row_count: 2,
                max_rows: 3,
                value: false,
                add_row_hide_expected: false,
                add_row_show_expected: true,
                icon_close_hide_expected: false,
                icon_close_show_expected: true,
            },
            {
                label: 'value is false, show add button when max is 0',
                row_count: 2,
                max_rows: 0,
                value: false,
                add_row_hide_expected: false,
                add_row_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',
                row_count: 3,
                max_rows: 3,
                value: false,
                add_row_hide_expected: false,
                add_row_show_expected: false,
                icon_close_hide_expected: false,
                icon_close_show_expected: true,
            },
        ].forEach(function (_a) {
            var label = _a.label, row_count = _a.row_count, max_rows = _a.max_rows, value = _a.value, add_row_hide_expected = _a.add_row_hide_expected, add_row_show_expected = _a.add_row_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_row_hide_called = false;
                var add_row_show_called = false;
                var icon_close_hide_called = false;
                var icon_close_show_called = false;
                var addRow = {
                    click: sinon.stub(),
                    hide: function () {
                        add_row_hide_called = true;
                        return;
                    },
                    show: function () {
                        add_row_show_called = true;
                        return;
                    },
                };
                var del_row = {
                    hide: function () {
                        icon_close_hide_called = true;
                        return;
                    },
                    show: function () {
                        icon_close_show_called = true;
                        return;
                    },
                };
                var table = { find: sinon.stub() };
                table.find.withArgs('.delrow').returns(del_row);
                table.find.withArgs('tbody > tr').returns({ length: row_count });
                var $content = CommonResources_1.createJqueryContent();
                $content.find.withArgs('.groupTable > tbody > tr:first').returns({
                    each: sinon.stub(),
                });
                $content.find.withArgs('table.groupTable').returns(table);
                $content.find.withArgs('table').returns({ hasClass: sinon.stub() });
                $content.find.withArgs('.delrow').returns(del_row);
                $content.find.withArgs('.action').returns({ live: sinon.stub() });
                $content.find.withArgs('.addrow:first').returns(addRow);
                var group = CommonResources_1.createGroup('foo', [], [], false, '', max_rows);
                var sut = CommonResources_1.createSut(TableGroupUi_1.TableGroupUi, {
                    $content: $content,
                    group: group,
                });
                var quote = CommonResources_1.createQuote();
                sut.init(quote);
                sut.hideAddRemove(value);
                expect(add_row_hide_called).to.equal(add_row_hide_expected);
                expect(add_row_show_called).to.equal(add_row_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, 