/* global expect */

describe('Form 3.3.7', function() {
    let Component, c1, testDiv;
    const descriptor = '/EAMD.ucp/Components/com/twitter/Bootstrap/Form/4.0.0/Form.component.xml';

    it('should create a testDiv and get the Class ', async() => {
        testDiv = document.createElement('div');
        testDiv.classList.add('hidden');
        document.body.appendChild(testDiv);
        Component = await ONCE.dropSupport.loadDescriptor(descriptor);
    });
    it('testDiv element should be a div and Form class should exists', done => {
        expect(testDiv).to.be.an.instanceof(HTMLElement);
        expect(Component).to.be.an.instanceof(Function);
        done();
    });
    it('should create 1 instance of Form and add it into testDiv', done => {
        c1 = Component.getInstance().init();
        expect(c1).to.be.an.instanceof(Component);

        expect(c1).has.hasOwnProperty('properties');
        expect(c1.properties).hasOwnProperty('classes');
        // expect(c1.properties.classes).to.be.a('string');
        c1.defaultView.append(document.body);

        done();
    });

    it('should remove instances of Form and check testDiv for empty', done => {
        c1.defaultView.remove();
        const componentViews = UcpComponentSupport.getAllUcpViews();
        expect(componentViews).to.be.an.instanceof(Array);
        expect(testDiv.innerHTML).to.be.empty;
        done();
    });
    after(done => {
        testDiv.remove();
        done();
    });
});