Skip to content
Snippets Groups Projects
Select Git revision
  • bb9f787732b01e0e1681b19fd67e9bc46ae2389d
  • main default protected
  • drip-server-timing
  • compress-middleware
  • v2.11.0
  • v2.10.0
  • v2.9.2
  • v2.9.1
  • v2.9.0
  • v2.8.0
  • v2.7.0
  • v2.6.0
  • v2.5.6
  • v2.5.5
  • v2.5.4
  • v2.5.3
  • v2.5.2
  • v2.5.1
  • v2.5.0
  • v2.4.2
  • v2.4.1
  • v2.4.0
  • v2.3.0
  • v2.2.2
24 results

README.md

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);
    
            });
    
        });
    
    
    })