Skip to content

Commit

Permalink
fix: allow matcher as the top-level value of a query string
Browse files Browse the repository at this point in the history
Fixes #510
  • Loading branch information
mefellows committed Sep 24, 2020
1 parent d7a39c5 commit 2922f8f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/dsl/interaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,19 @@ describe("Interaction", () => {
}

it("is passed with matcher", () => {
request.query = term({
generate: "limit=50&status=finished&order=desc",
matcher: "^limit=[0-9]+&status=(finished)&order=(desc|asc)$",
})
expect(
new Interaction()
.uponReceiving("request")
.withRequest(request)
.json().request
).to.have.any.keys("query")
})

it("is passed with matcher as the value", () => {
request.query = {
"id[]": eachLike("1"),
}
Expand Down
4 changes: 4 additions & 0 deletions src/dsl/interaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ export class Interaction {
* @param query
*/
private queryObjectIsValid(query: QueryObject) {
if (isMatcher(query)) {
return
}

Object.values(query).every(value => {
if (
isMatcher(value) ||
Expand Down

0 comments on commit 2922f8f

Please sign in to comment.