nchaulet / httpbackend

Http backend mock module for protractor
MIT License
28 stars 10 forks source link

headers parameter isn't supported in respond function #10

Closed amanzyuk closed 9 years ago

amanzyuk commented 9 years ago

We need to check Authorization header value in get request. Something like following:

backend.whenGET('/api/', hr).respond(
    function (method, url, data, headers) {
      console.log(headers);
      for (var key in headers) {
        if (key === 'Authorization') {
          var val = headers[key];
          if (val === 'Token TestToken') {
            return [200, {}, {}];
          } else {
            console.log('Incorrect token: ' + val);
            return [401, {}, {}];
          }
        }
      }
      return [401, {}, {}];
    }
  );

But headers parameter is undefined.

nchaulet commented 9 years ago

Fixed in versions 1.2.0 thanks for your's PR