Comparing version 0.2.0 to 0.3.0
0.3.0 / 2012-09-24 | ||
================== | ||
* add `https.Server` support [fengmk2] | ||
0.2.0 / 2012-08-29 | ||
@@ -3,0 +8,0 @@ ================== |
@@ -9,2 +9,3 @@ | ||
, http = require('http') | ||
, https = require('https') | ||
, assert = require('assert') | ||
@@ -43,3 +44,4 @@ , Request = request.Request; | ||
if (!addr) app.listen(portno); | ||
this.url = 'http://127.0.0.1:' + portno + path; | ||
var protocol = app instanceof https.Server ? 'https' : 'http'; | ||
this.url = protocol + '://127.0.0.1:' + portno + path; | ||
} | ||
@@ -79,3 +81,3 @@ | ||
// body | ||
if (b && 'function' != typeof b) this._body = b; | ||
if ('function' != typeof b) this._body = b; | ||
return this; | ||
@@ -82,0 +84,0 @@ } |
{ | ||
"name": "supertest", | ||
"version": "0.2.0", | ||
"version": "0.3.0", | ||
"description": "Super-agent driven library for testing HTTP servers", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,1 @@ | ||
# SuperTest | ||
@@ -21,3 +20,3 @@ | ||
```js | ||
var request = require('./') | ||
var request = require('supertest') | ||
, express = require('express'); | ||
@@ -89,2 +88,10 @@ | ||
Perform the request and invoke `fn(err, res)`. | ||
Perform the request and invoke `fn(err, res)`. | ||
## Notes | ||
Inspired by [api-easy](https://github.com/flatiron/api-easy) minus vows coupling. | ||
## License | ||
MIT |
var request = require('..') | ||
, https = require('https') | ||
, fs = require('fs') | ||
, path = require('path') | ||
, express = require('express'); | ||
@@ -40,2 +43,24 @@ | ||
it('should work with a https server', function(done){ | ||
var app = express(); | ||
app.get('/', function(req, res){ | ||
res.send('hey'); | ||
}); | ||
var fixtures = path.join(__dirname, 'fixtures'); | ||
var server = https.createServer({ | ||
key: fs.readFileSync(path.join(fixtures, 'test_key.pem')), | ||
cert: fs.readFileSync(path.join(fixtures, 'test_cert.pem')) | ||
}, app); | ||
request(server) | ||
.get('/') | ||
.end(function(err, res){ | ||
res.should.have.status(200); | ||
res.text.should.equal('hey'); | ||
done(); | ||
}); | ||
}) | ||
it('should work with .send() etc', function(done){ | ||
@@ -97,3 +122,21 @@ var app = express(); | ||
.expect(200, 'foo', done) | ||
}) | ||
}); | ||
describe("when the body argument is an empty string", function() { | ||
it("should not quietly pass on failure", function(done) { | ||
var app = express(); | ||
app.get('/', function(req, res){ | ||
res.send('foo'); | ||
}); | ||
request(app) | ||
.get('/') | ||
.expect(200, '') | ||
.end(function(err, res){ | ||
err.message.should.equal('expected \'\' response body, got \'foo\''); | ||
done(); | ||
}); | ||
}); | ||
}); | ||
}) | ||
@@ -236,2 +279,2 @@ | ||
}) | ||
}) | ||
}) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
16443
11
417
95
0
2
5