0
我有以下工廠。現在
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("&");
}
}
}
);
}]);
,我想測試一下,在這種情況下'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8'
調用Api.MakePost({},{data: {}}, function() {})
正確的標題數據即當設置正確。使用$ httpBackend,Jasmine和Spies來測試這個場景嗎?