thanks in advance, I am trying to test a function that is called on ajax success callback and then inside a forEach. (trackTaxonomyEvent())
But I am always getting
Error: Expected spy trackTaxonomyEvent to have been called
If I move the function out of the forEach it works.
code.js
saveFanzones: function(closeOnSave) {
this.selectedTaxonomyCollection.create({
taxonomy_ids: newTaxaonomiesId.join(',')
}, {
success: function() {
_.forEach(this.selectedTaxonomyCollection.where({
user_selected: true
}), function(fanzoneModel) {
var params = {
id: fanzoneModel.get('id')
};
this.trackTaxonomyEvent('fanzone:join',params);
}.bind(this));
}.bind(this)
});
});code.spec.js
it('Ajax call correct URL', function() {
spyOn($, 'ajax').and.callFake(function(params) {
params.success('1');
});
spyOn(view, 'trackTaxonomyEvent').and.callThrough();
view.saveFanzones();
expect(view.trackTaxonomyEvent).toHaveBeenCalled();
});--
You received this message because you are subscribed to the Google Groups "Jasmine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jasmine-js+...@googlegroups.com.
To post to this group, send email to jasmi...@googlegroups.com.
Visit this group at https://groups.google.com/group/jasmine-js.
For more options, visit https://groups.google.com/d/optout.