-
Notifications
You must be signed in to change notification settings - Fork 27.4k
feat(MockHttpExpectation): matchData supports function as data #2981
feat(MockHttpExpectation): matchData supports function as data #2981
Conversation
Add support for passing function as validating data: - To avoid hacking test method of RegExp - Optionally overwrite toString method of fn to show validation tips
|
@kenspirit Thnx for this PR. Could you go over the attached checklist? Main points are the CLA and documentation update. |
Thx for the update. I have signed the CLA previously before making this PR. |
Since we are duck-typing regexp then you can get the required functionality already with:
and you could add a
Is there any real benefit in adding this or just update the documentation? [Devil's Advocate here] |
Hi @petebacondarwin , True that duck-typing works and that is also what I love about JS, the flexibility. It looks like the API is not complete to support function type and we need to "hack" it somehow. |
Hi @petebacondarwin , Almost forgot. There is one real benefit. function prettyPrint(data) {
return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp)
? data
: angular.toJson(data);
} |
:-) Good stuff On 17 July 2013 21:50, Ken Chen [email protected] wrote:
|
Is that I should also update the documentation so that this PR can be accepted? |
- change param desc for when, whenPost, whenPut, expect, expectPost, expectPut, expectPATCH
Add support for passing function as validating data: - To avoid hacking test method of RegExp - Optionally overwrite `toString` method of fn to show validation tips - change docs: param description for `when`, `whenPost`, `whenPut`, `expect`, `expectPost`, `expectPut`, `expectPATCH` Closes: angular#2981
@kenspirit - Thanks for this PR. Landed on master as 08daa77 |
Thanks. @petebacondarwin |
Add support for passing function as validating data: