2

I have a javascript function like the one below

function_name: function(){
    var self = this;
    $.get('something',{
        target : 'something',
        param1 : 'somevalue',
    })
}

I need to stub $.get function using teaspoon. could I get any snippet to solve using teaspoon or sinon stub

Updated

I was able to solve this issue using the following code

var ajax_get_stub = sinon.stub($, 'get').returns($.Deferred().resolve({}).promise());

expect(ajax_get_stub.withArgs('resource', { param1: 'value' }).calledOnce).to.be(true);

$.get.restore();
T. Junghans
  • 11,385
  • 7
  • 52
  • 75
Lohith
  • 891
  • 1
  • 6
  • 5

0 Answers0