javascript - checking that an event fired with mocha -
how can test element fired event mocha? i've got ugly solution working, it's not readable, takes long time time out when fails, , doesn't give failure messaging.
describe('test-element', function() { var el; beforeeach(function() { el = document.createelement('test-element'); }); it('fires save event', function(done) { el.addeventlistener('save', function() { done(); }); el.save(); });
in perfect world, think cooler.
it('fires save event', function() { el.save(); expect(el).to.have.firedevent('save'); }); });
am going right way? there better approach or custom matcher library should using?
how spying on fire
function...?
not sure stubbing/spying library you're using lets sinon.js. like...
var spy = sinon.spy(el, 'fire'); el.save(); expect(spy.calledwith('save')).to.be.true;
Comments
Post a Comment