Skip to content
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

calrify query behaviour #566

Merged
merged 1 commit into from
May 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/_api-mocking/mock_matcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,11 @@ parameters:
- strings, numbers and booleans are coerced to strings
- arrays of values are coerced to repetitions of the key
- all other values, including `undefined`, are coerced to an empty string
The request will be matched whichever order keys appear in the query string
The request will be matched whichever order keys appear in the query string.
Any query parameters sent in the request which are not included in the keys of the object provided will be ignored.
examples:
- |-
{"q": "cute+kittenz"} // matches '?q=cute kittenz' or ?q=cute+kittenz'
{"q": "cute+kittenz"} // matches '?q=cute kittenz' or ?q=cute+kittenz' or ?q=cute+kittenz&mode=big'
- |-
{"tags": ["cute", "kittenz"]} // matches `?q=cute&q=kittenz`
- |-
Expand Down
12 changes: 12 additions & 0 deletions test/specs/routing/query-string-matching.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,18 @@ describe('query string matching', () => {
expect(fm.calls(true).length).to.equal(2);
});

it('ignore irrelevant query strings', async () => {
fm.mock(
{
query: { a: 'b', c: 'd' },
},
200
).catch();

await fm.fetchHandler('http://a.com?a=b&c=d&e=f');
expect(fm.calls(true).length).to.equal(1);
});

it('match an empty query string', async () => {
fm.mock(
{
Expand Down