import ReactTransitionEvents from '../../lib/ReactTransitionEvents'; describe('ReactTransitionEvents', () => { it('should export add and remove functions', () => { expect(ReactTransitionEvents).to.have.property('addEndEventListener').that.is.a('function'); expect(ReactTransitionEvents).to.have.property('removeEndEventListener').that.is.a('function'); }); it('should support transition events', done => { let div = document.createElement('div'); div.style.cssText = 'position:absolute; left:0; top:0; width:100px; height:100px; background:#000; transition:all 50ms ease;'; document.body.appendChild(div); setTimeout(() => { let onEnd = sinon.spy(); ReactTransitionEvents.addEndEventListener(div, onEnd); div.style.left = '100px'; setTimeout(() => { expect(onEnd).to.have.been.calledOnce; document.body.removeChild(div); done(); }, 100); }); }); it('should support animation events', done => { let div = document.createElement('div'); div.style.cssText = 'position:absolute; left:0; top:0; width:100px; height:100px; background:#000;'; div.innerHTML = ` `; document.body.appendChild(div); setTimeout(() => { let onEnd = sinon.spy(); ReactTransitionEvents.addEndEventListener(div, onEnd); div.className = 'slide'; setTimeout(() => { expect(onEnd).to.have.been.calledOnce; document.body.removeChild(div); done(); }, 100); }); }); });