"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var history_1 = require("../../partial-src/component/history");
function run() {
    var _this = this;
    var interval = 500;
    describe("Test history", function () {
        it("Test history", function (done) {
            var his = new history_1.History();
            if (his.state.state !== "waiting")
                throw new Error("Invalid initial state");
            var end = false;
            var end2 = false;
            his.registerBackButton("popup2", function () {
                end2 = true;
            });
            his.registerBackButton("popup", function () {
                end = true;
            });
            window.history.back();
            setTimeout(function () {
                if (!end) {
                    throw new Error("Invalid popstate");
                }
                window.history.back();
                setTimeout(function () {
                    if (!end2) {
                        throw new Error("Invalid multi popup");
                    }
                    done();
                }, interval);
            }, interval);
        });
        it("Test goto", function (done) {
            var his = new history_1.History();
            var wheres = [];
            his.events.listenBy(_this, "goto", function (where) {
                wheres.push(where);
            });
            var key = Math.random().toString().slice(4, 10);
            his.goto("/" + key);
            setTimeout(function () {
                window.history.back();
                setTimeout(function () {
                    if (wheres.length != 2) {
                        done(new Error("Invalid goto"));
                        return;
                    }
                    if (wheres[0].indexOf(key) < 0) {
                        done(new Error("Invalid goto"));
                        return;
                    }
                    done();
                }, interval);
            }, interval);
        });
    });
}
exports.run = run;
//# sourceMappingURL=history.test.js.map