-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(ngMocks): add expectRoute and whenRoute shortcuts with colon param matching #12406
feat(ngMocks): add expectRoute and whenRoute shortcuts with colon param matching #12406
Conversation
We found a Contributor License Agreement for you (the sender of this pull request), but were unable to find agreements for the commit author(s). If you authored these, maybe you used a different email address in the git commits than was used to sign the CLA (login here to double check)? If these were authored by someone else, then they will need to sign a CLA as well, and confirm that they're okay with these being contributed to Google. |
CLAs look good, thanks! |
CLA signed and builds passing. Any feedback here? |
Any thoughts or suggestions on this? Potentially a 1.4.x or 1.5 addition? |
Have not seen much action on the Angular repo lately, accidentally closed the PR (was going to comment, thought was just closing the comment, sorry!), reopened. |
I can rebase this on master and squash the commits if necessary. Still haven't received any feedback. @angular |
I like the look of this @dmaloneycalu please do rebase. We probably won't be able to get to it until after AngularConnect now. |
The tests might also make good use of the |
BTW, the real benefit I see in this change comes from the added So, we need docs and tests for that :) |
@petebacondarwin can do. @gkalpak I'll add additional tests for the parameter addition and rewrite some of the tests to take advantage of the |
|
@@ -1251,20 +1251,21 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) { | |||
* data string and returns true if the data is as expected. | |||
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header | |||
* object and returns true if the headers match the current definition. | |||
* @param {(Array)=} keys Array of keys to assign to regex matches in the respond params for the url. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this needs a bit more explanation for people coming to this documentation without looking at the code. Perhaps we could have a single section in the ngMock.$httpBackend description that explains what can now be done with regexes and keys then simply refer each fo these parameter descriptions to that section?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll take a stab at this and notify you when I've pushed it.
…am matching Add whenRoute method to $httpBackend to support matching similar to API backends, which handles responses based on the query to a particular route. Also includes params in the respond function to give access to both query params and route colon delimited values. This is a feature request and is not associated with any open issue
I'm not an English professor, so feel free to let me know if anything isn't well defined enough |
Thanks @dmaloneycalu I will take a look |
}); | ||
``` | ||
* | ||
* By default, query parameters on requested urls are parsed onto the params object, so a requsted url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
requsted --> requested
I did a bunch of tidy up on the docs and landed. Thanks @dmaloneycalu |
See #12406 (comment). Thanks @gkalpak :-)
Sorry on the indentation, was trying to be thorough checking since my editor is usually 4 spaces for indentation. Glad I could contribute. |
👍 |
Adds a
whenRoute()
andexpectRoute()
function to$httpBackend
service to make mocking out responses similar to writing API routes on a server. Also includes colon delimited param matching so that expect and when handlers can match requests in the form of/user/:id
, identical to the way ngRoute matches urls in an Angular application.Here's an example file that reflects one of the use cases for the feature (paged API responses).