Skip to content
Snippets Groups Projects
Select Git revision
  • 1b3bdd2f3e7db1bfd6529dac3ad88725915608cc
  • master default protected
  • 1.31
  • 4.28.0
  • 4.27.0
  • 4.26.0
  • 4.25.5
  • 4.25.4
  • 4.25.3
  • 4.25.2
  • 4.25.1
  • 4.25.0
  • 4.24.3
  • 4.24.2
  • 4.24.1
  • 4.24.0
  • 4.23.6
  • 4.23.5
  • 4.23.4
  • 4.23.3
  • 4.23.2
  • 4.23.1
  • 4.23.0
23 results

Monster_DOM.Template.html

Blame
  • notify.mjs 2.35 KiB
    //import {getGlobal} from "../../../../source/types/global.mjs";
    import * as chai from 'chai';
    import {chaiDom} from "../../../util/chai-dom.mjs";
    import {initJSDOM} from "../../../util/jsdom.mjs";
    
    let expect = chai.expect;
    chai.use(chaiDom);
    
    // const global = getGlobal();
    //
    // let html1 = `
    //     <div id="test1">
    //     </div>
    // `;
    //
    // // language=HTML
    // let html2 = `
    //     <div id="test2">
    //         <monster-notify data-monster-options='{}'></monster-notitfy>
    //     </div>
    // `;
    
    let Notify, fetchReference;
    
    describe('Notify', function () {
    
        before(function (done) {
            initJSDOM().then(() => {
                import("../../../../source/components/notify/notify.mjs").then((m) => {
                    Notify = m['Notify'];
                    done()
                }).catch(e => done(e))
            });
        })
    
        describe('document.createElement', function () {
            it('should instance of notify', function () {
    
                
                    expect(document.createElement('monster-notify')).is.instanceof(Notify);
                
    
    
            });
    
            it('should have messages', function (done) {
    
                let mocks = document.getElementById('mocks');
                const notify = document.createElement('monster-notify');
                let i = 0;
                notify.push("this is message " + i++);
                notify.push("this is message " + i++);
                notify.push("this is message " + i++);
    
                const mutationobserver = new MutationObserver(function (mutations) {
    
                    for (const [, mutation] of mutations.entries()) {
                        if (mutation.addedNodes[0].tagName === 'MONSTER-NOTIFY') {
    
                            setTimeout(() => {
                                mutationobserver.disconnect();
                                try {
    
                                    const messages = notify.shadowRoot.querySelectorAll('monster-notify-message');
                                    // 3 options (see fetch above)
                                    expect(messages.length).is.equal(3);
    
                                } catch (e) {
                                    return done(e);
                                }
    
                                done();
    
    
                            }, 0)
                        }
                    }
    
                });
    
                mutationobserver.observe(mocks, {childList: true});
                mocks.appendChild(notify);
    
            });
    
        });
    
    
    })