"use strict";
/**
 * Test case for StackedGroupUi
 *
 *  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 StackedGroupUi_1 = require("../../../src/ui/group/StackedGroupUi");
var CommonResources_1 = require("./CommonResources");
describe('ui.group.StackedGroupUi', function () {
    describe('#showField', function () {
        [
            {
                field: 'foo_bar',
                index: 0,
            },
            {
                field: 'bar_foo',
                index: 1,
            },
        ].forEach(function (_a) {
            var field = _a.field, index = _a.index;
            it("it shows the header for " + field + " when group fields are visible", function () {
                var container = CommonResources_1.createContainer();
                var content = CommonResources_1.createContent();
                content.querySelector
                    .withArgs('div.stacked-container')
                    .returns(container);
                var sut = CommonResources_1.createSut(StackedGroupUi_1.StackedGroupUi, {
                    field: field,
                    content: content,
                });
                var removeClass = sinon.stub();
                var header = {
                    classList: {
                        remove: removeClass,
                    },
                };
                sut.getCurrentIndex = sinon.stub().returns(10);
                sut.hasVisibleField = sinon.stub().withArgs(index).returns(true);
                container.querySelectorAll.withArgs('dl').returns([header, header]);
                var quote = CommonResources_1.createQuote();
                content.querySelectorAll.withArgs('dl').returns([header, header]);
                sut.init(quote);
                sut.showField(field, index);
                expect(removeClass.calledOnce).to.be.true;
            });
        });
    });
    describe('#hideField', function () {
        [
            {
                field: 'foo_baz',
                index: 0,
            },
            {
                field: 'baz_foo',
                index: 1,
            },
        ].forEach(function (_a) {
            var field = _a.field, index = _a.index;
            it("it hides the header for " + field + " when no group fields are visible", function () {
                var container = CommonResources_1.createContainer();
                var content = CommonResources_1.createContent();
                content.querySelector
                    .withArgs('div.stacked-container')
                    .returns(container);
                var sut = CommonResources_1.createSut(StackedGroupUi_1.StackedGroupUi, {
                    field: field,
                    content: content,
                });
                var addClass = sinon.stub();
                var header = {
                    classList: {
                        add: addClass,
                    },
                };
                sut.getCurrentIndex = sinon.stub().returns(10);
                sut.hasVisibleField = sinon.stub().withArgs(index).returns(false);
                container.querySelectorAll.withArgs('dl').returns([header, header]);
                var quote = CommonResources_1.createQuote();
                content.querySelectorAll.withArgs('dl').returns([header, header]);
                sut.init(quote);
                sut.hideField(field, index);
                expect(addClass.calledOnce).to.be.true;
            });
        });
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiU3RhY2tlZEdyb3VwVWlUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiU3RhY2tlZEdyb3VwVWlUZXN0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFBQTs7Ozs7Ozs7Ozs7Ozs7Ozs7OztHQW1CRzs7QUFFSCxJQUFNLE1BQU0sR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUMsTUFBTSxFQUNuQyxLQUFLLEdBQUcsT0FBTyxDQUFDLE9BQU8sQ0FBQyxDQUFDO0FBRTNCLHVFQUEyRTtBQUMzRSxxREFLMkI7QUFFM0IsUUFBUSxDQUFDLHlCQUF5QixFQUFFO0lBQ2xDLFFBQVEsQ0FBQyxZQUFZLEVBQUU7UUFDckI7WUFDRTtnQkFDRSxLQUFLLEVBQUUsU0FBUztnQkFDaEIsS0FBSyxFQUFFLENBQUM7YUFDVDtZQUNEO2dCQUNFLEtBQUssRUFBRSxTQUFTO2dCQUNoQixLQUFLLEVBQUUsQ0FBQzthQUNUO1NBQ0YsQ0FBQyxPQUFPLENBQUMsVUFBQyxFQUFjO2d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