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

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -