Currently, I am in the process of writing unit tests for my AngularJS application. In order to perform these tests, I am utilizing the $httpBackend to mock the $http request internally.
During the testing phase, I make use of $httpBackend.expectGET to ensure that the behavior of my application's request is exact.
As an example, I have a Params-Object:
parameters = {
name : 'Monkey',
crazy : false,
desc : 'Nobody',
};
The Http-Get request in my application is:
return $http.get(this.uri + '/' + id, {params : parameters});
Within my unit test, I anticipate the following:
$httpBackend.expectGET(instance.uri + '/' + returnValues.id + '?' + query).respond(200, object);
Here, "query" consists of the elements of the object concatenated with '=' and '&'. Therefore, I expect the URL to be:
www.example.com/api/v1/object/1?name=Monkey&crazy=false&desc=Nobody
Unfortunately, the actual URL I receive looks like this:
www.example.com/api/v1/object/1?crazy=false&desc=Nobody&name=Monkey
Is it possible that $http is sorting the parameters based on the keys in the object for the "params"?