"use strict";
/**
 *  Test case for LeftAlignAncestorAwareStyler
 *
 *  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 LeftAlignAncestorAwareStyler_1 = require("../../../src/ui/styler/LeftAlignAncestorAwareStyler");
var chai_1 = require("chai");
var sinon = require('sinon');
before(function () {
    this.jsdom = require('jsdom-global')();
});
after(function () {
    this.jsdom();
});
describe('ui.styler.LeftAlignAncestorAwareStyler', function () {
    describe('style', function () {
        it('sets left 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');
            var ggparent = container.querySelector('#ggparent');
            element.getBoundingClientRect = sinon.stub().returns({ left: 800 });
            ggparent.getBoundingClientRect = sinon.stub().returns({ left: 500 });
            if (element === null) {
                throw new Error('Unable to find element');
            }
            var sut = new LeftAlignAncestorAwareStyler_1.LeftAlignAncestorAwareStyler();
            sut.style(element, 3);
            chai_1.expect(element.style.left).to.equal('-300px');
        });
        it('does not set left 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 LeftAlignAncestorAwareStyler_1.LeftAlignAncestorAwareStyler();
            sut.style(element, 2);
            chai_1.expect(element.style.left).to.equal('');
        });
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTGVmdEFsaWduQW5jZXN0b3JBd2FyZVN0eWxlclRlc3QuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyJMZWZ0QWxpZ25BbmNlc3RvckF3YXJlU3R5bGVyVGVzdC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUE7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7R0FtQkc7O0FBRUgsb0dBQXdHO0FBRXhHLDZCQUE0QjtBQUM1QixJQUFNLEtBQUssR0FBRyxPQUFPLENBQUMsT0FBTyxDQUFDLENBQUM7QUFFL0IsTUFBTSxDQUFDO0lBQ0wsSUFBSSxDQUFDLEtBQUssR0FBRyxPQUFPLENBQUMsY0FBYyxDQUFDLEVBQUUsQ0FBQztBQUN6QyxDQUFDLENBQUMsQ0FBQztBQUVILEtBQUssQ0FBQztJQUNKLElBQUksQ0FBQyxLQUFLLEVBQUUsQ0FBQztBQUNmLENBQUMsQ0FBQyxDQUFDO0FBRUgsUUFBUSxDQUFDLHdDQUF3QyxFQUFFO0lBQ2pELFFBQVEsQ0FBQyxPQUFPLEVBQUU7UUFDaEIsRUFBRSxDQUFDLGlEQUFpRCxFQUFFO1lBQ3BELElBQU0sU0FBUyxHQUFHLFFBQVEsQ0FBQyxhQUFhLENBQUMsS0FBSyxDQUFDLENBQUM7WUFFaEQsU0FBUyxDQUFDLFNBQVMsR0FBRyxnVUFRTCxDQUFDO1lBRWxCLElBQU0sT0FBTyxHQUFnQixTQUFTLENBQUMsYUFBYSxDQUFDLE1BQU0sQ0FBQyxDQUFDO1lBQzdELElBQU0sUUFBUSxHQUFnQixTQUFTLENBQUMsYUFBYSxDQUFDLFdBQVcsQ0FBQyxDQUFDO1lBRW5FLE9BQU8sQ0FBQyxxQkFBcUIsR0FBRyxLQUFLLENBQUM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