私は最近、私のjavascript関数の1つにe.preventDefault()
を追加しました。これはジャスミン仕様を破ったものです。私はspyOn(e, 'preventDefault').andReturn(true);
を試しましたが、e
は未定義のエラーです。どのように私はe.preventDefault()?
jasmineテストでe.preventDefault()をスタブする
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();
});
解決策は機能しませんでしたか? –
@Asadいいえ、私はそれを削除しました – Huy
あなたの 'spyOn(e、 'preventDefault')'はOKですが、あなたは 'it()'の 'showTopic()'に 'e'を渡しませんでした。それはポイントですか? – zbynour