मिला है मैं इस मॉड्यूल (2) के लिए एक परीक्षण (1) को लागू करने की कोशिश कर रहा हूं।
मेरा उद्देश्य यह जांचना है कि कोई विशेष ईवेंट ट्रिगर होने पर संग्रह प्राप्त किया जाता है या नहीं।
जैसा कि आप मेरी टिप्पणी से देख सकते हैं (2) मुझे संदेश Error: Expected a spy, but got Function.
मॉड्यूल काम करता है लेकिन परीक्षण विफल रहता है। कोई विचार?एक जासूस की उम्मीद है, लेकिन फंक्शन
(1)
// jasmine test module
describe('When onGivePoints is fired', function() {
beforeEach(function() {
spyOn(this.view.collection, 'restartPolling').andCallThrough();
app.vent.trigger('onGivePoints');
});
it('the board collection should be fetched', function() {
expect(this.view.collection.restartPolling).toHaveBeenCalled();
// Error: Expected a spy, but got Function.
});
});
(2)
// model view module
return Marionette.CompositeView.extend({
initialize: function() {
this.collection = new UserBoardCollection();
this.collection.startPolling();
app.vent.on('onGivePoints', this.collection.restartPolling);
},
// other code
});
क्या हो रहा है यह देखने के लिए पर्याप्त कोड नहीं है। कृपया केवल व्यक्तिगत कार्यों से अधिक शामिल करें - ऑब्जेक्ट परिभाषा को शामिल करें जिसमें फ़ंक्शंस हैं, और कोड जो कम से कम ऑब्जेक्ट्स को तुरंत चालू करता है। –
@DerickBailey आपके समय के लिए धन्यवाद। मैंने मोड कोड के साथ अपना प्रश्न अपडेट किया। –
मैं जैस्मीन के बजाए क्विनिट का उपयोग करता हूं, लेकिन ऐप.वेंट.ट्रिगर को आपका कॉल पहले से पहले "इसे" विधि में नहीं होना चाहिए? – codemonkey