Try

It depends how to do your call. If they end up being url encoded:

$httpBackend.expectPOST('/rest/test?local=fr').respond(jsonSuccess)

If it is JSON

$httpBackend.expectPOST('/rest/test', {locale: "fr"}).respond(jsonSuccess)

Either way everything is pretty clear in the documentation

On Wednesday, July 16, 2014 9:26:22 AM UTC-4, Olivier THIERRY wrote:
>
> Hi,
>
> I wrote a Angular service that encapsulates calls to REST services.
> This service adds some parameters to the URL and I want to write a unit 
> test that verifies these parameters were added as expected.
> I use $httpBackend to mock the HTTP request in my test, but I can't find a 
> way to see the URL that was called.
>
> Here is the unit test I wrote :
>
>     it(" - Appel d'un service public", inject(function ($rootScope, 
> $httpBackend, RestService) {
>
>         $httpBackend.when('JSONP').respond(jsonSuccess);
>
>         var resolvedValue;
>         var promise = RestService.call('/rest/test');
>         promise.then(function (value) {
>             resolvedValue = value;
>         });
>         $httpBackend.flush();
>         $rootScope.$apply();
>
>         expect(resolvedValue).toBe("myData");
>         
>         // Need something like that
>         expect($httpBackend.url.locale).toBe('fr');
>
>     }));
>
> Thanks for any help !
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to