Skip to content

Commit

Permalink
tests use cases for variable GET responses
Browse files Browse the repository at this point in the history
  • Loading branch information
targoo authored and sideshowcoder committed May 23, 2016
1 parent a988f21 commit c246508
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ Release History
* fix improper handling of carriage return in windows #79 (@git-jiby-me)
* fix handling for urls in request body #90 (@wadtech)
* documentation and test cases for cors headers #91 (@wadtech)
* enable matching raw request body rather than property-based #96 (@ftes)
* fix query string param handling #97 (@wadtech @targoo)

### 0.3.7
* The regex for matching request, was not considering arrays in the request JSON
Expand Down Expand Up @@ -384,6 +386,7 @@ Contributors
* [git-jiby-me](https://github.com/git-jiby-me)
* [wadtech](https://github.com/wadtech)
* [ftes](https://github.com/ftes)
* [targoo](https://github.com/targoo)

License
-------
Expand Down
18 changes: 18 additions & 0 deletions spec/canned.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,24 @@ describe('canned', function () {
can(req, res)
})

it("should select the right response based on the GET request data", function (done) {
req.url = "/multiple_get_responses?" + querystring.stringify({ foo: "apostrophe" })
res.end = function (content) {
expect(content).toEqual(JSON.stringify({"response": "response with 'apostrophes'"}))
done()
}
can(req, res)
})

it("should select the right response based on the GET request data", function (done) {
req.url = "/multiple_get_responses?" + querystring.stringify({ foo: "bar", index: 1 })
res.end = function (content) {
expect(content).toEqual(JSON.stringify({"response": "response with index 1"}))
done()
}
can(req, res)
})

it("should select the first response with no query string", function (done) {
req.url = "/multiple_get_responses"
res.end = function (content) {
Expand Down

0 comments on commit c246508

Please sign in to comment.