import {initJSDOM} from "../../../util/jsdom.mjs";
import {getGlobal} from "../../../../source/types/global.mjs";
import * as chai from 'chai';
import {chaiDom} from "../../../util/chai-dom.mjs";

let expect = chai.expect;
chai.use(chaiDom);

const global = getGlobal();


describe('Host', function () {

    let host;
    let html1 = `
        <monster-host id="host1"></monster-host>
    `;

    before(function (done) {
        initJSDOM().then(() => {
            import("../../../../source/components/host/host.mjs").then((m) => {
                host = m['Host'];
                done()
            }).catch(e => done(e))

        });
    })

    beforeEach(() => {
        let mocks = document.getElementById('mocks');
        mocks.innerHTML = html1;

        // register own datasource, after the form is loaded
        // because in the wild, the form is parsed before the datasource is registered
        //form.registerDatasource('test3', test3Datasource);


    });    

    afterEach(() => {
        let mocks = document.getElementById('mocks');
        mocks.innerHTML = "";
        localStorage.removeItem('test-key')
    })
    
    
    it('should run', function (done) {

        let mocks = document.getElementById('mocks');
        const formControl = document.createElement('monster-host');
        mocks.appendChild(formControl);

        setTimeout(() => {
            try {
                expect(document.getElementById('mocks')).contain.html('<monster-host data-monster-objectlink="Symbol(@schukai/monster/dom/custom-element@@options-updater-link)"></monster-host>')
            } catch (e) {
                return done(e);
            }

            done();
        }, 0)





    });


});
