Esempio n. 1
0
        it('should properly call handler with SyntheticEvent object', () => {
            const spy = sinon.spy();

            mountToDomSync(
                domNode,
                createNode('div').attrs({ id : 'id1', onScroll : spy }));

            simulate.scroll(document.getElementById('id1'));

            const e = spy.args[0][0];

            expect(e).to.be.an(SyntheticEvent);
            expect(e.type).to.be.equal('scroll');
        });
Esempio n. 2
0
        it('should properly remove handler', () => {
            const spy = sinon.spy();

            mountToDomSync(
                domNode,
                createNode('div').attrs({ id : 'id1', onScroll : spy }));

            mountToDomSync(
                domNode,
                createNode('div').attrs({ id : 'id1' }));

            simulate.scroll(document.getElementById('id1'));

            expect(spy.called).not.to.be.ok();
        });
Esempio n. 3
0
        it('should properly replace handler for bubbleable events', () => {
            const spy1 = sinon.spy(),
                spy2 = sinon.spy();

            mountToDomSync(
                domNode,
                createNode('div').attrs({ id : 'id1', onScroll : spy1 }));

            mountToDomSync(
                domNode,
                createNode('div').attrs({ id : 'id1', onScroll : spy2 }));

            simulate.scroll(document.getElementById('id1'));

            expect(spy1.called).not.to.be.ok();
            expect(spy2.called).to.be.ok();
        });
Esempio n. 4
0
        it('should properly add handler', () => {
            const spy1 = sinon.spy(),
                spy2 = sinon.spy(),
                spy3 = sinon.spy();

            mountToDomSync(
                domNode,
                createNode('div').attrs({ onScroll : spy1 }).children([
                    createNode('div').attrs({ id : 'id1', onScroll : spy2 }),
                    createNode('div').attrs({ id : 'id2', onScroll : spy3 })
                ]));

            simulate.scroll(document.getElementById('id1'));

            expect(spy1.called).not.to.be.ok();
            expect(spy2.called).to.be.ok();
            expect(spy3.called).not.to.be.ok();
        });