1

I have this function :

viewModel.prototype.save = function(){
    $.ajax({
        url: "/vacation_booking/save",
        //dataType: "json",
        type: "POST",
        data: "idUser=" + this.idUser() + "&name=" + this.name() + "&lastName=" + this.lastName() + "&age=" + this.age(),
        success: function (data){
            $('#info').html(data);
            $('#info').show(function(){
                $(this).fadeOut(5000);
            });

        },
        failure: function(){
            alert("Unsuccessful");
        }
    });
  }

how can i test the success and error functions in this case?

i've seen some examples of callback testing with jasmine in other stackoverflow questions but in all the examples the function that they were testing received the callback function as a parameter as you can see here:

How do I verify jQuery AJAX events with Jasmine?

Community
  • 1
  • 1
user2018726
  • 638
  • 2
  • 12
  • 23
  • I think Jasmine has some timeout functionality and maybe you could use that to create a test. [Jasmine asynchronous specs ...](https://github.com/pivotal/jasmine/wiki/Asynchronous-specs) – Razvan May 30 '14 at 20:37

0 Answers0