"use strict";
/**
 * Test case for MobileNav
 *
 *  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;
var MobileNav_1 = require("../../../src/ui/nav/MobileNav");
describe('MobileNav', function () {
    it('sets onclick handlers', function () {
        var _a = getMocks(), header = _a.header, steps = _a.steps, sections = _a.sections, nav_menu = _a.nav_menu;
        new MobileNav_1.MobileNav(nav_menu);
        expect(header.onclick).to.not.equal(undefined);
        expect(steps[0].onclick).to.not.equal(undefined);
        expect(sections[0].onclick).to.not.equal(undefined);
    });
    it('stops initializing if required elements are not found', function () {
        var _a = getMocks(), nav_menu = _a.nav_menu, header = _a.header;
        nav_menu.getElementsByClassName = function (selector) {
            switch (selector) {
                case 'mobile-nav':
                    return [null];
                default:
                    return [header];
            }
        };
        new MobileNav_1.MobileNav(nav_menu);
        expect(header.onclick).to.be.undefined;
    });
    describe('#stepChanged', function () {
        it('updates header text', function () {
            var _a = getMocks(), header = _a.header, nav_menu = _a.nav_menu;
            var sut = new MobileNav_1.MobileNav(nav_menu);
            sut.stepChanged('foo');
            expect(header.innerHTML).to.equal('<span>foo</span>');
        });
    });
    describe('#stepChanged', function () {
        it('hides nav', function () {
            var _a = getMocks(), nav = _a.nav, nav_menu = _a.nav_menu;
            var add_class_called = false;
            nav.classList.add = function () {
                add_class_called = true;
            };
            var sut = new MobileNav_1.MobileNav(nav_menu);
            sut.stepChanged('foo');
            expect(add_class_called).to.be.true;
        });
    });
});
function getMocks() {
    var sections = getSectionElements();
    var steps = getStepElements();
    var nav = getNavElement(steps, sections);
    var header = getNavHeaderElement();
    var nav_menu = getNavMenu(nav, header);
    return {
        sections: sections,
        steps: steps,
        nav: nav,
        header: header,
        nav_menu: nav_menu,
    };
}
function getNavMenu(nav, header) {
    return {
        getElementsByClassName: function (selector) {
            switch (selector) {
                case 'mobile-nav':
                    return [nav];
                default:
                    return [header];
            }
        },
    };
}
function getSectionElements() {
    return [{}];
}
function getStepElements() {
    return [{}];
}
function getNavElement(steps, sections) {
    return {
        getElementsByClassName: function (selector) {
            switch (selector) {
                case 'section-item':
                    return sections;
                default:
                    return steps;
            }
        },
        classList: {
            add: function () { },
            remove: function () { },
            toggle: function () { },
        },
    };
}
function getNavHeaderElement() {
    return {};
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiTW9iaWxlTmF2VGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIk1vYmlsZU5hdlRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBOzs7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBbUJHOztBQUVILElBQU0sTUFBTSxHQUFHLE9BQU8sQ0FBQyxNQUFNLENBQUMsQ0FBQyxNQUFNLENBQUM7QUFFdEMsMkRBQStEO0FBRS9ELFFBQVEsQ0FBQyxXQUFXLEVBQUU7SUFDcEIsRUFBRSxDQUFDLHVCQUF1QixFQUFFO1FBQ3BCLElBQUEsS0FBc0MsUUFBUSxFQUFFLEVBQS9DLE1BQU0sWUFBQSxFQUFFLEtBQUssV0FBQSxFQUFFLFFBQVEsY0FBQSxFQUFFLFFBQVEsY0FBYyxDQUFDO1FBRXZELElBQUkscUJBQUcsQ0FBQyxRQUFRLENBQUMsQ0FBQztRQUVsQixNQUFNLENBQUMsTUFBTSxDQUFDLE9BQU8sQ0FBQyxDQUFDLEVBQUUsQ0FB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