I am pretty new to Jasmine testing so maybe I am doing something wrong. The problem is that I have simple AJAX call using jQuery. The method is simple:
function sendSomeDataViaAJAX( link, data ) {
$.ajax(link, { dataType: 'json', method: 'post', data: data }).
// all other listeners
}
From my code in Jasmine I invoke this method like this (using AJAX mocking)
var dataToBeSent = { id : 666 };
sendSomeDataViaAJAX(dataToBeSent, '/fake/addr');
var request = jasmine.Ajax.requests.mostRecent();
expect(request.data()).toEqual({ id : 666});
The problem is that I get:
Expected Object({id: ['666'] }) to equal Object({ id: 666 })
Could anyone answer why is that happening? When I log passed object in a console before call and also in the method (but before invoking $.ajax) everything looks ok - there is no array present. The only problem is with value returned from
request.data()
method call. Any suggestions? Why do I get my 666 value wrapped in array?