test for options support
This commit is contained in:
parent
362aa087ca
commit
9a90e7d0b9
|
@ -41,6 +41,12 @@ TestServer.prototype.router = function(req, res) {
|
|||
res.end('text');
|
||||
}
|
||||
|
||||
if (p === '/options') {
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Allow', ['GET', 'HEAD', 'OPTIONS']);
|
||||
res.end('hello world');
|
||||
}
|
||||
|
||||
if (p === '/html') {
|
||||
res.statusCode = 200;
|
||||
res.setHeader('Content-Type', 'text/html');
|
||||
|
|
13
test/test.js
13
test/test.js
|
@ -607,6 +607,19 @@ describe('node-fetch', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it('should allow OPTIONS request', function() {
|
||||
url = base + '/options';
|
||||
opts = {
|
||||
method: 'OPTIONS'
|
||||
};
|
||||
return fetch(url, opts).then(function(res) {
|
||||
expect(res.status).to.equal(200);
|
||||
expect(res.statusText).to.equal('OK');
|
||||
expect(res.headers.get('allow')).to.equal('GET, HEAD, OPTIONS');
|
||||
expect(res.body).to.be.an.instanceof(stream.Transform);
|
||||
});
|
||||
});
|
||||
|
||||
it('should reject decoding body twice', function() {
|
||||
url = base + '/plain';
|
||||
return fetch(url).then(function(res) {
|
||||
|
|
Loading…
Reference in New Issue