"use strict";
/**
 *  Test case for WidthAncestorAwareStyler
 *
 *  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 WidthAncestorAwareStyler_1 = require("../../../src/ui/styler/WidthAncestorAwareStyler");
var chai_1 = require("chai");
before(function () {
    this.jsdom = require('jsdom-global')();
    Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
        get: function () {
            return 500;
        },
    });
});
after(function () {
    this.jsdom();
});
describe('ui.styler.WidthAncestorAwareStyler', function () {
    describe('style', function () {
        it('sets the width of the element based on its ancestors', function () {
            var container = document.createElement('div');
            container.innerHTML = "<div id=\"ggparent\">\n                    <div id=\"gparent\">\n                        <div id=\"parent\">\n                            <div class=\"foo\">\n                                Foo bar\n                            </div>\n                        </div>\n                    </div>\n                </div>";
            var element = container.querySelector('.foo');
            if (element === null) {
                throw new Error('Unable to find element');
            }
            var sut = new WidthAncestorAwareStyler_1.WidthAncestorAwareStyler();
            sut.style(element, 3);
            chai_1.expect(element.style.width).to.equal('500px');
        });
        it('does not set width if element has no parent', function () {
            var container = document.createElement('div');
            container.innerHTML = "<div class=\"foo\">\n                    Foo bar\n                </div>";
            var element = container.querySelector('.foo');
            if (element === null) {
                throw new Error('Unable to find element');
            }
            var sut = new WidthAncestorAwareStyler_1.WidthAncestorAwareStyler();
            sut.style(element, 2);
            chai_1.expect(element.style.width).to.equal('');
        });
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ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