lundi 24 août 2015

How do I test my HTTP call when I use a config to build the URL?

In my project I build some of my HTTP requests like so:

var options = {
    params:{
        foo: 'bar'
        hello: world
    }
};
$http.get("my/service", options)

Which means that the final HTTP call looks something like my/service?foo=bar&hello=worldVar

How do I setup my $httpBackend to account for this?

The problems I see are:

  1. I'm not guaranteed order in my parameters with this style, which means setting up the first parameter in expectGet will be hard.
  2. Its hard to test calls when I really don't care about the parameters

Aucun commentaire:

Enregistrer un commentaire