-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle queries (i.e. "?name=Pikachu") #23
Comments
Still trying to steal some time away to work on this. Hopefully be done this week. |
No problem! I'd love to hear your comments on the questions above. |
Had some time to look around more of the code and think about your questions.
So for the global feature we will add 2 config options, forceLowerCaseQueries, stripQueries. Anything else? |
Thanks! |
feat(apimock): add query param functionality Close #23
We now handle URL query parameters. Ref #23
…aram $http’s config.param can include nested objects and arrays, but parsing them to a valid file path will have to wait. So they’re not being included in the path for now. Ref #23
If anyone wants to discuss this feature, I've opened a Gitter chatroom. |
From 97.2% to 100%. * Removed unnecessary guard clauses in things I borrowed from AngularJS source code (mostly for IE8 support). * Used $filter instead of manually removing elements from array in removeFallback(). * Added tests to better flex the query handling feature in #23. ** Testing array of objects. ** Undefined and empty URL param values. ** Date-type in params object. Closes #44
From 97.2% to 100%. * Removed unnecessary guard clauses in things I borrowed from AngularJS source code (mostly for IE8 support). * Used $filter instead of manually removing elements from array in removeFallback(). * Added tests to better flex the query handling feature in #23. ** Testing array of objects. ** Undefined and empty URL param values. ** Date-type in params object. Closes #44
From 97.2% to 100%. * Removed unnecessary guard clauses in things I borrowed from AngularJS source code (mostly for IE8 support). * Used $filter instead of manually removing elements from array in removeFallback(). * Disable video and screenshots on SauceLabs as the tests aren't visual. * Added tests to better flex the query handling feature in #23. ** Testing array of objects. ** Undefined and empty URL param values. ** Date-type in params object. Closes #44
Currently query parameters in the API URL are just stripped out. There should be an optional setting for including them in the redirect.
Use case
Better testing of search-like features where one could test search terms that will give different search results, such as no results, a few results, a lot of results, spelling suggestions, etc.
Usage
Config set in the
config()
by settingstripQueries
tofalse
(default istrue
). Sample:Descoped (do this later as a separate feature):
Local and global flag set on individual requests, which would be perfect for isolated testing of a autocompletion type search. To not pollute the
$http
config we should scope it withinapiMock
, but that requires another feature (to allow config objects instead of justtrue/false
). Sample:Effect
/api/pokemon?name=Pikachu
no longer strips the query and redirects to/mock_data/pokemon.get.json
. Instead it redirects to/mock_data/pokemon/name=pikachu.get.json
(similar to mock url #13 where/api/pokemon
would redirect to/mock_data/pokemon/get.json
instead of/mock_data/pokemon.get.json
, but for now we only do this for URL's with queries).Pikaču
becomespika%C4%8Du
).strength=...&name=...
becomesname=...&strength=...
).The text was updated successfully, but these errors were encountered: