Test empty status text (#1069)

This commit is contained in:
Travis D. Warlick, Jr 2021-02-28 15:05:23 -05:00 committed by GitHub
parent 8eeeec18c1
commit f2ff9ecd04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 0 deletions

View File

@ -696,6 +696,13 @@ describe('node-fetch', () => {
});
});
it('should handle response with no status text', () => {
const url = `${base}no-status-text`;
return fetch(url).then(res => {
expect(res.statusText).to.equal('');
});
});
it('should handle no content response', () => {
const url = `${base}no-content`;
return fetch(url).then(res => {

View File

@ -70,6 +70,10 @@ export default class TestServer {
res.end('text');
}
if (p === '/no-status-text') {
res.writeHead(200, '', {}).end();
}
if (p === '/options') {
res.statusCode = 200;
res.setHeader('Allow', 'GET, HEAD, OPTIONS');