I have this following factory.
services.factory('Api', ['$resource', function ($resource) {
return $resource(urlPath, {
'action': 'get',
'entity': 'Entity'
}, {
MakePost: {
method: "POST",
isArray: false,
headers: {'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'},
transformRequest: function(obj) {
var str = [];
for (var p in obj) {
str.push(encodeURIComponent(p) + '=' + encodeURIComponent(obj[p]));
}
return str.join("&");
}
}
}
);
}]);
Now, i would like to test, when calling Api.MakePost({},{data: {}}, function () {})
the correct header data i.e in this case 'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'
is set correctly. Is there away to test this scenario in angularjs, using $httpBackend, Jasmine and spies?