angularjs - Unit testing a $http.post, jquery issue? -
trying make unit test form post.
here http.post
$http({ method: 'post', url: '/api/project', data: $.param($scope.project), headers: { 'content-type': 'application/x-www-form-urlencoded' } // set headers angular passing info form data (not request payload) })
when run unit test, get:
syntaxerror: unexpected token p
it's p in $.*p*aram.
i have included jquery @ top in karma file. , recognizes $.
this (incomplete) test:
it('should return status 200 when posting data', function(){ scope.submit(); mockbackend.expectpost('/api/project', {title: 'test'}).respond({id: 2}); mockbackend.flush(); });
any ideas do?
Comments
Post a Comment