angularjs - testing post load in a httpBackend mock -
i trying test service in angular, , having difficulty testing put request. want test see content of request correct. first attempt this:
httpbackend.expectput('/data/category/1',newcategory).respond(201,''); service.addcategory(newcategory); httpbackend.flush();
hoping newcategory object turn json. fails:
typeerror: object not function
another attempt use function testing request load:
var isnewcategory = function(str){ return json.parse(str) == newcategory; }; httpbackend.expectput('/data/category/1',isnewcategory).respond(201,''); service.addcategory(newcategory); httpbackend.flush();
this produces :
error: expected put /data/category/1 different data expected: function (str){ return json.parse(str) == newcategory; } got: {"name":"new category","id":"2","parentid":"1"} @ $httpbackend (c:/users/abizhanzadeh@cta.loc/documents/work
can me please?
Comments
Post a Comment