मैं बुनियादी jQuery AJAX अनुरोधों के लिए कुछ BDD चश्मा लिखने के लिए जैस्मीन का उपयोग करने की कोशिश कर रहा हूं। मैं वर्तमान में स्टैंडअलोन मोड (यानी के माध्यम से SpecRunner.html
) में जैस्मीन का उपयोग कर रहा हूं । मैंने jquery और अन्य .js फ़ाइलों को लोड करने के लिए SpecRunner कॉन्फ़िगर किया है। किसी भी विचार क्यों निम्नलिखित काम नहीं करता है? has_returned सत्य नहीं हुआ, यहाँ तक कि "युप्पी" भी सोचा! चेतावनी ठीक दिखाता है।
describe("A jQuery ajax request should be able to fetch...", function() {
it("an XML file from the filesystem", function() {
$.ajax_get_xml_request = { has_returned : false };
// initiating the AJAX request
$.ajax({ type: "GET", url: "addressbook_files/addressbookxml.xml", dataType: "xml",
success: function(xml) { alert("yuppi!"); $.ajax_get_xml_request.has_returned = true; } });
// waiting for has_returned to become true (timeout: 3s)
waitsFor(function() { $.ajax_get_xml_request.has_returned; }, "the JQuery AJAX GET to return", 3000);
// TODO: other tests might check size of XML file, whether it is valid XML
expect($.ajax_get_xml_request.has_returned).toEqual(true);
});
});
मैं कैसे परीक्षण करूं कि कॉलबैक कहा गया है? जैस्मीन के साथ async jQuery के परीक्षण से संबंधित ब्लॉग / सामग्री के लिए कोई संकेत बहुत सराहना की जाएगी।