Ho aggiunto di recente uno e.preventDefault()
a una delle mie funzioni javascript e ha infranto le specifiche del mio gelsomino. Ho provato spyOn(e, 'preventDefault').andReturn(true);
ma ottengo e
errore non definito. Come faccio a stub e.preventDefault()?
Stub e.preventDefault() in un test al gelsomino
showTopic: function(e) {
e.preventDefault();
midParent.prototype.showTopic.call(this, this.model, popup);
this.topic.render();
}
it("calls the parent", function() {
var parentSpy = spyOn(midParent.prototype, "showTopic");
this.view.topic = {
render: function() {}
};
this.view.showTopic();
expect(parentSpy).toHaveBeenCalled();
});
La soluzione non ha funzionato? –
@Asad no, ecco perché l'ho cancellato – Huy
Il tuo 'spyOn (e, 'preventDefault')' è ok ma non hai passato 'e' a' showTopic() 'nel' it() '. È questo il punto? – zbynour