"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
document.body.appendChild(document.createElement('dijiengine'));
const RoomstayThemeEngine_1 = __importDefault(require("../../../src/providers/RoomstayThemeEngine"));
describe('Roomstay Theme Engine', () => {
    RoomstayThemeEngine_1.default.EngineContainer = document.createElement('div');
    beforeEach(() => {
        RoomstayThemeEngine_1.default.init();
    });
    describe('Registering Scripts', () => {
        it('Appends a script based on url to the target container', () => {
            var _a, _b;
            expect((_a = RoomstayThemeEngine_1.default.ScriptContainer) === null || _a === void 0 ? void 0 : _a.childNodes.length).toBe(0);
            RoomstayThemeEngine_1.default.loadScript('https://notarealscript.com/wejustneedatestscript', 'cool script');
            expect((_b = RoomstayThemeEngine_1.default.ScriptContainer) === null || _b === void 0 ? void 0 : _b.childNodes.length).toBe(1);
        });
    });
    describe('Finding Elements on the Dom created by Roomstay', () => {
        it('creates an element, and inserts it to the dom with a specific name', () => {
            expect(RoomstayThemeEngine_1.default.EngineContainer.childNodes.length).toBe(2);
            RoomstayThemeEngine_1.default.createElementOrReuseExisting('script', 'vgssource');
            expect(RoomstayThemeEngine_1.default.EngineContainer.childNodes.length).toBe(3);
        });
        it('creates a new node with a prefixed name', () => {
            var _a;
            RoomstayThemeEngine_1.default.ScriptContainer = document.createElement('div');
            const container = RoomstayThemeEngine_1.default.createElementOrReuseExisting('script', 'vgssource');
            expect((_a = container.getAttribute('name')) === null || _a === void 0 ? void 0 : _a.startsWith('roomstay')).toBeTruthy();
        });
        it('returns found node if it already exists', () => {
            RoomstayThemeEngine_1.default.createElementOrReuseExisting('script', 'vgssource');
            expect(RoomstayThemeEngine_1.default.EngineContainer.childNodes.length).toBe(3);
            RoomstayThemeEngine_1.default.createElementOrReuseExisting('script', 'vgssource');
            expect(RoomstayThemeEngine_1.default.EngineContainer.childNodes.length).toBe(3);
        });
    });
});
//# sourceMappingURL=RoomstayThemeEngine.test.js.map