atecarlos / protractor-http-mock

A library designed to work alongside Protractor for setting up mocks for your HTTP ajax requests.
MIT License
173 stars 70 forks source link

Added support for interceptors that return a promise to resolve a config object #42

Closed brandonroberts closed 9 years ago

brandonroberts commented 9 years ago

Interceptors can return a config object, or a promise that resolves a config object. This adds support for handling either scenario before returning the response promise.

jrencz commented 9 years ago

:+1:

atecarlos commented 9 years ago

Awesome pull request @brandonroberts and with tests! I'll be reviewing this soon and merging it in to the main branch.

deyceg commented 9 years ago

@brandonroberts Great work! Ran in to this problem yesterday. Doesnt look like it deals with the response equivalent?

brandonroberts commented 9 years ago

@deyceg I believe the response equivalent is already being handled. If no mock is provided it just returns the $http promise, and if a mock is provided its wrapped in a promise which will be resolved once the request is made.

deyceg commented 9 years ago

@brandonroberts Thats correct!

The call to getTransformedResponse is assuming that the response is just an object, and after the interceptors have been applied it still assumes its an object, but one of the interceptors may return a $promise containing a response object instead

brandonroberts commented 9 years ago

@deyceg Ok. the PR has been updated to handle response promises also.

brandonroberts commented 9 years ago

Bump? @atecarlos

atecarlos commented 9 years ago

Hi @brandonroberts . This weekend I have set aside some time to work through this and get it merged in. Thanks again for the PR.