"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = Object.setPrototypeOf ||
        ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
        function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
var WidgetGiveSlots = (function (_super) {
    __extends(WidgetGiveSlots, _super);
    function WidgetGiveSlots() {
        var _this = _super.call(this) || this;
        _this.childWidget = new R.TestView.WidgetWithSlots();
        return _this;
    }
    return WidgetGiveSlots;
}(R.TestView.WidgetGiveSlots));
function run() {
    var wgs;
    var wis;
    describe("Widget slot test", function () {
        it("Create widget", function () {
            wgs = new WidgetGiveSlots();
        });
        it("Can refer to data-id given to child widget", function () {
            var text = wgs.UI.header.textContent.toString().trim();
            if (text !== "HEADER") {
                throw new Error("Failed to reference");
            }
        });
        it("Should beable to merge child classes", function () {
            wgs.VM.parentClass = "parent-class";
            wgs.childWidget.VM.childClass = "child-class";
            var classes = ["parent-set-widget", "child-set-widget", "parent-class", "child-class"];
            for (var _i = 0, classes_1 = classes; _i < classes_1.length; _i++) {
                var className = classes_1[_i];
                if (!wgs.childWidget.node.classList.contains(className)) {
                    throw new Error("Fail to merge child widget:" + className);
                }
            }
        });
        it("Child can refer to gived child widget by data-id", function () {
            var same = wgs.childWidget.UI.header === wgs.UI.header;
            if (!same) {
                throw new Error("Failed to match header");
            }
            same = wgs.childWidget.UI.body === wgs.UI.body;
            if (!same) {
                throw new Error("Failed to match body");
            }
        });
        it("Class should merge correctly", function () {
            wgs.VM.parentSlotClass = "parent-set";
            wgs.childWidget.VM.childSlotClass = "slot-set";
            var classes = ["parent-set", "slot-set", "slot-header", "parent-header"];
            for (var _i = 0, classes_2 = classes; _i < classes_2.length; _i++) {
                var name_1 = classes_2[_i];
                if (!wgs.childWidget.UI.header.classList.contains(name_1)) {
                    throw new Error("Fail to merge class:" + name_1);
                }
            }
        });
    });
    describe("Common widget test", function () {
        var tum;
        var tm;
        it("Widget include common widget", function () {
            Leaf.Widget.namespace.clear();
            Leaf.Widget.namespace.include(R.TestView.TestModal);
        });
        it("Widget use common widget", function () {
            tum = new R.TestView.TestUseModal();
            var succeed = tum.node.widget instanceof R.TestView.TestModal;
            if (!succeed) {
                throw new Error("Fail to create namespace");
            }
            tm = tum.node.widget;
        });
        it("Common widget should have dynamics properties attached", function () {
            tum.VM.parentHeaderSet = true;
            tum.VM.useModalSet = true;
            tm.VM.slotHeaderSet = true;
            tm.VM.modalSet = true;
            var classes;
            classes = ["modal", "use-modal", "use-modal-set", "modal", "modal-set"];
            for (var _i = 0, classes_3 = classes; _i < classes_3.length; _i++) {
                var name_2 = classes_3[_i];
                if (!tum.node.classList.contains(name_2)) {
                    console.error(tum.node.classList);
                    throw new Error("Fail to transfer class:" + name_2);
                }
            }
            classes = ["parent-header", "parent-header-set", "slot-header", "slot-header-set"];
            for (var _a = 0, classes_4 = classes; _a < classes_4.length; _a++) {
                var name_3 = classes_4[_a];
                if (!tum.UI.header.classList.contains(name_3)) {
                    console.error(tum.UI.header.classList);
                    throw new Error("Fail to transfer slot class:" + name_3);
                }
            }
        });
    });
}
exports.run = run;
//# sourceMappingURL=widget.test.js.map