Angular.js: Custom URI encoding makes it hard to mock $http requests

Created on 23 Jul 2013  路  2Comments  路  Source: angular/angular.js

I'm having a hell of a time trying to mock $http with $httpBackend. Basically if you are mocking GET, JSONP or DELETE requests, the only way to mock them is to actually express the full URI including the query. However this gets quite challenging because Angular uses it's own query encoding functions which do not appear to be publicly accessible.

The only solution I have for now is to hard-code the URI in my test.

I'd suggest one of two solutions:

  1. Improve the $httpBackend mocking API so it is possible to express the query parameters with an object
  2. Expose the query encoding functions

I'd actually suggest both are good ideas.

$http ngMock inconvenient feature

Most helpful comment

Is this issue still being worked on? Whats the status?

All 2 comments

10853 should help with (2), review would be appreciated. Going to look into (1) in the coming days.

Is this issue still being worked on? Whats the status?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kishanmundha picture kishanmundha  路  3Comments

tdumitrescu picture tdumitrescu  路  3Comments

WesleyKapow picture WesleyKapow  路  3Comments

ashclarke picture ashclarke  路  3Comments

jtorbicki picture jtorbicki  路  3Comments