ฉันต้องการจำลองการโทร ajax ไปยังเซิร์ฟเวอร์โดยใช้ jasmine และทดสอบ Deferred Object ที่เสร็จสิ้นแล้วและล้มเหลว
ขณะนี้ฉันกำลังทำอยู่จริงจึงพยายามส่งสายจำนวนมากไปยังเซิร์ฟเวอร์
ฉันจะแก้ไขรหัสต่อไปนี้เป็น
mySpy = spyOn(backendController, 'submitForm').andCallThrough();
// it makes a real call to the server
mySpy = spyOn(backendController, 'submitForm');
// it does not make a real call to the server but I get the following error
// Cannot call method 'done' of undefined
นี่คือโค้ดเกี่ยวกับ doSubmitForm
doSubmitForm: function (backendController) {
backendController.submitForm(message.val())
.done(this.onSuccess)
.fail(this.onError);
});