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";
import {ResizeObserverMock} from "../../../util/resize-observer.mjs";

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

const global = getGlobal();


describe('Details', function () {

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

    before(function (done) {
        initJSDOM().then(() => {
            import("../../../../source/components/host/details.mjs").then((m) => {
                host = m['Details'];

                if(!global.ResizeObserver) {
                    global.ResizeObserver = ResizeObserverMock;
                }
                
                done()
            }).catch(e => done(e))

        });
        
        
        
    })

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

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

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

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

            done();
        }, 0)

    });

});
