"use strict";
/**
 *  Test case for getNthAncestor
 *
 *  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 AncestorAwareStyler_1 = require("../../../src/ui/styler/AncestorAwareStyler");
var chai_1 = require("chai");
describe('ui.styler.getNthAncestor', function () {
    describe('getNthAncestor', function () {
        it('gets the nth ancestor of an element', 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 expected = [
                container.querySelector('.foo'),
                container.querySelector('#parent'),
                container.querySelector('#gparent'),
                container.querySelector('#ggparent'),
            ];
            var target = expected[0];
            expected.forEach(function (elem, index) {
                var ancestor = AncestorAwareStyler_1.getNthAncestor(target, index);
                chai_1.expect(ancestor).to.equal(elem);
            });
        });
        it("doesn't get a non-existent ancestor", function () {
            var container = document.createElement('div');
            container.innerHTML = "<div class=\"foo\">Foo bar</div>";
            var target = container.querySelector('.foo');
            var ancestor = AncestorAwareStyler_1.getNthAncestor(target, 100);
            chai_1.expect(ancestor).to.be.null;
        });
    });
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2V0TnRoQW5jZXN0b3JUZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiZ2V0TnRoQW5jZXN0b3JUZXN0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