Skip to content

Commit

Permalink
Split request and response tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
moll committed Dec 11, 2015
1 parent d4f1a8e commit 104df53
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/index_test.js
Expand Up @@ -15,16 +15,20 @@ describe("FetchDefaults", function() {
fetch.Response.must.equal(Fetch.Response)
})

it("must request with resolved path and options", function*() {
it("must request with resolved path and options", function() {
var root = "https://example.com"
var fetch = defaults(Fetch, root, {headers: {"X-Time-Zone": "UTC"}})
var res = fetch("/models", {method: "POST"})
fetch("/models", {method: "POST"})

this.requests[0].method.must.equal("POST")
this.requests[0].url.must.equal("https://example.com/models")
this.requests[0].requestHeaders.must.eql({"x-time-zone": "UTC"})
})

it("must respond", function*() {
var res = defaults(Fetch, "https://example.com")("/models")
this.requests[0].respond(200, {}, "Hello")

res = yield res
res.status.must.equal(200)
;(yield res.text()).must.equal("Hello")
Expand Down

0 comments on commit 104df53

Please sign in to comment.