"use strict";
var src_1 = require('../../../../src');
function run() {
    describe('IonicApp', function () {
        describe('getActiveNav', function () {
            it('should get active NavController when using tabs with nested nav', function () {
                var nav = mockNav();
                app.setRootNav(nav);
                var tabs = mockTabs();
                var tab1 = mockTab(tabs);
                var tab2 = mockTab(tabs);
                nav.registerChildNav(tabs);
                tab2.setSelected(true);
                var nav2 = mockNav();
                var nav3 = mockNav();
                var nav4 = mockNav();
                tab1.registerChildNav(nav4);
                tab2.registerChildNav(nav2);
                tab2.registerChildNav(nav3);
                expect(app.getActiveNav()).toBe(nav3);
            });
            it('should get active NavController when using tabs', function () {
                var nav = mockNav();
                app.setRootNav(nav);
                var tabs = mockTabs();
                var tab1 = mockTab(tabs);
                var tab2 = mockTab(tabs);
                var tab3 = mockTab(tabs);
                nav.registerChildNav(tabs);
                tab2.setSelected(true);
                expect(app.getActiveNav()).toBe(tab2);
                tab2.setSelected(false);
                tab3.setSelected(true);
                expect(app.getActiveNav()).toBe(tab3);
            });
            it('should get active NavController when nested 3 deep', function () {
                var nav1 = mockNav();
                var nav2 = mockNav();
                var nav3 = mockNav();
                app.setRootNav(nav1);
                nav1.registerChildNav(nav2);
                nav2.registerChildNav(nav3);
                expect(app.getActiveNav()).toBe(nav3);
            });
            it('should get active NavController when nested 2 deep', function () {
                var nav1 = mockNav();
                var nav2 = mockNav();
                app.setRootNav(nav1);
                nav1.registerChildNav(nav2);
                expect(app.getActiveNav()).toBe(nav2);
            });
            it('should get active NavController when only one nav controller', function () {
                var nav = mockNav();
                app.setRootNav(nav);
                expect(app.getActiveNav()).toBe(nav);
            });
            it('should set/get the root nav controller', function () {
                var nav = mockNav();
                app.setRootNav(nav);
                expect(app.getRootNav()).toBe(nav);
            });
            it('should not get an active NavController if there is not root set', function () {
                expect(app.getActiveNav()).toBeNull();
                expect(app.getRootNav()).toBeNull();
            });
        });
        var app;
        var config;
        var platform;
        var _cd;
        function mockNav() {
            return new src_1.Nav(null, null, null, config, null, null, null, null, null);
        }
        function mockTabs() {
            return new src_1.Tabs(null, null, null, config, null, null, null);
        }
        function mockTab(parentTabs) {
            return new src_1.Tab(parentTabs, app, config, null, null, null, null, null, _cd);
        }
        beforeEach(function () {
            config = new src_1.Config();
            platform = new src_1.Platform();
            app = new src_1.IonicApp(config, null, platform);
            _cd = {
                reattach: function () { },
                detach: function () { }
            };
        });
    });
}
exports.run = run;