-
-
Notifications
You must be signed in to change notification settings - Fork 926
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Accept http.request object as first argument
- Loading branch information
Showing
5 changed files
with
53 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
var tape = require('tape'); | ||
var got = require('../'); | ||
var server = require('./server.js'); | ||
var s = server.createServer(); | ||
|
||
s.on('/test', function (req, res) { | ||
res.end(req.url); | ||
}); | ||
|
||
s.on('/?test=wow', function (req, res) { | ||
res.end(req.url); | ||
}); | ||
|
||
tape('setup', function (t) { | ||
s.listen(s.port, function () { | ||
t.end(); | ||
}); | ||
}); | ||
|
||
tape('accepts url.parse object as first argument', function (t) { | ||
got({host: s.host, port: s.port, path: '/test'}, function (err, data) { | ||
t.error(err); | ||
t.equal(data, '/test'); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
tape('extends parsed string with opts', function (t) { | ||
got(s.url, {path: '/test'}, function (err, data) { | ||
t.error(err); | ||
t.equal(data, '/test'); | ||
t.end(); | ||
}); | ||
}); | ||
|
||
tape('cleanup', function (t) { | ||
s.close(); | ||
t.end(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters