Browse Source

Revert "temporary fix for T2892 (`const` gives "read-only" error)"

This reverts commit c4045e3de6.
http2
Vsevolod Strukchinsky 9 years ago
parent
commit
00ee3b47e2
  1. 5
      package.json
  2. 2
      test/gzip.js
  3. 10
      test/headers.js
  4. 2
      test/http.js
  5. 8
      test/https.js
  6. 2
      test/json.js
  7. 24
      test/post.js
  8. 6
      test/unix-socket.js

5
package.json

@ -69,9 +69,6 @@
"xo": "*" "xo": "*"
}, },
"xo": { "xo": {
"esnext": true, "esnext": true
"rules": {
"prefer-const": 0
}
} }
} }

2
test/gzip.js

@ -3,7 +3,7 @@ import test from 'ava';
import got from '../'; import got from '../';
import {createServer} from './helpers/server'; import {createServer} from './helpers/server';
let testContent = 'Compressible response content.\n'; const testContent = 'Compressible response content.\n';
let s; let s;

10
test/headers.js

@ -16,12 +16,12 @@ test.before('setup', async () => {
}); });
test('user-agent', async t => { test('user-agent', async t => {
let headers = (await got(s.url, {json: true})).body; const headers = (await got(s.url, {json: true})).body;
t.is(headers['user-agent'], 'https://github.com/sindresorhus/got'); t.is(headers['user-agent'], 'https://github.com/sindresorhus/got');
}); });
test('accept-encoding', async t => { test('accept-encoding', async t => {
let headers = (await got(s.url, {json: true})).body; const headers = (await got(s.url, {json: true})).body;
t.is(headers['accept-encoding'], 'gzip,deflate'); t.is(headers['accept-encoding'], 'gzip,deflate');
}); });
@ -34,17 +34,17 @@ test('accept header with json option', async t => {
}); });
test('host', async t => { test('host', async t => {
let headers = (await got(s.url, {json: true})).body; const headers = (await got(s.url, {json: true})).body;
t.is(headers.host, `localhost:${s.port}`); t.is(headers.host, `localhost:${s.port}`);
}); });
test('transform names to lowercase', async t => { test('transform names to lowercase', async t => {
let headers = (await got(s.url, {headers: {'USER-AGENT': 'test'}, json: true})).body; const headers = (await got(s.url, {headers: {'USER-AGENT': 'test'}, json: true})).body;
t.is(headers['user-agent'], 'test'); t.is(headers['user-agent'], 'test');
}); });
test('zero content-length', async t => { test('zero content-length', async t => {
let headers = (await got(s.url, {headers: {'content-length': 0}, body: 'sup', json: true})).body; const headers = (await got(s.url, {headers: {'content-length': 0}, body: 'sup', json: true})).body;
t.is(headers['content-length'], '0'); t.is(headers['content-length'], '0');
}); });

2
test/http.js

@ -52,7 +52,7 @@ test('error with code', async t => {
}); });
test('buffer on encoding === null', async t => { test('buffer on encoding === null', async t => {
let data = (await got(s.url, {encoding: null})).body; const data = (await got(s.url, {encoding: null})).body;
t.ok(Buffer.isBuffer(data)); t.ok(Buffer.isBuffer(data));
}); });

8
test/https.js

@ -10,15 +10,15 @@ let cert;
let caRootKey; let caRootKey;
let caRootCert; let caRootCert;
let pemP = pify(pem, Promise); const pemP = pify(pem, Promise);
test.before('setup', async () => { test.before('setup', async () => {
let caKeys = await pemP.createCertificate({days: 1, selfSigned: true}); const caKeys = await pemP.createCertificate({days: 1, selfSigned: true});
caRootKey = caKeys.serviceKey; caRootKey = caKeys.serviceKey;
caRootCert = caKeys.certificate; caRootCert = caKeys.certificate;
let keys = await pemP.createCertificate({ const keys = await pemP.createCertificate({
serviceCertificate: caRootCert, serviceCertificate: caRootCert,
serviceKey: caRootKey, serviceKey: caRootKey,
serial: Date.now(), serial: Date.now(),
@ -50,7 +50,7 @@ test('make request to https server', async t => {
}); });
test('make request to https server with ca', async t => { test('make request to https server with ca', async t => {
let {body} = await got(s.url, { const {body} = await got(s.url, {
strictSSL: true, strictSSL: true,
ca: caRootCert, ca: caRootCert,
headers: {host: 'sindresorhus.com'} headers: {host: 'sindresorhus.com'}

2
test/json.js

@ -38,7 +38,7 @@ test('parses response', async t => {
}); });
test('not parses responses without a body', async t => { test('not parses responses without a body', async t => {
let {body} = await got(`${s.url}/204`, {json: true}); const {body} = await got(`${s.url}/204`, {json: true});
t.is(body, ''); t.is(body, '');
}); });

24
test/post.js

@ -25,48 +25,48 @@ test.before('setup', async () => {
}); });
test('GET can have body', async t => { test('GET can have body', async t => {
let {body, headers} = await got.get(s.url, {body: 'hi'}); const {body, headers} = await got.get(s.url, {body: 'hi'});
t.is(body, 'hi'); t.is(body, 'hi');
t.is(headers.method, 'GET'); t.is(headers.method, 'GET');
}); });
test('sends strings', async t => { test('sends strings', async t => {
let {body} = await got(s.url, {body: 'wow'}); const {body} = await got(s.url, {body: 'wow'});
t.is(body, 'wow'); t.is(body, 'wow');
}); });
test('sends Buffers', async t => { test('sends Buffers', async t => {
let {body} = await got(s.url, {body: new Buffer('wow')}); const {body} = await got(s.url, {body: new Buffer('wow')});
t.is(body, 'wow'); t.is(body, 'wow');
}); });
test('sends Streams', async t => { test('sends Streams', async t => {
let {body} = await got(s.url, {body: intoStream(['wow'])}); const {body} = await got(s.url, {body: intoStream(['wow'])});
t.is(body, 'wow'); t.is(body, 'wow');
}); });
test('works with empty post response', async t => { test('works with empty post response', async t => {
let {body} = await got(`${s.url}/empty`, {body: 'wow'}); const {body} = await got(`${s.url}/empty`, {body: 'wow'});
t.is(body, ''); t.is(body, '');
}); });
test('content-length header with string body', async t => { test('content-length header with string body', async t => {
let {body} = await got(`${s.url}/headers`, {body: 'wow', json: true}); const {body} = await got(`${s.url}/headers`, {body: 'wow', json: true});
t.is(body['content-length'], '3'); t.is(body['content-length'], '3');
}); });
test('content-length header with Buffer body', async t => { test('content-length header with Buffer body', async t => {
let {body} = await got(`${s.url}/headers`, {body: new Buffer('wow'), json: true}); const {body} = await got(`${s.url}/headers`, {body: new Buffer('wow'), json: true});
t.is(body['content-length'], '3'); t.is(body['content-length'], '3');
}); });
test('content-length header with Stream body', async t => { test('content-length header with Stream body', async t => {
let {body} = await got(`${s.url}/headers`, {body: intoStream(['wow']), json: true}); const {body} = await got(`${s.url}/headers`, {body: intoStream(['wow']), json: true});
t.is(body['content-length'], undefined); t.is(body['content-length'], undefined);
}); });
test('content-length header is not overriden', async t => { test('content-length header is not overriden', async t => {
let {body} = await got(`${s.url}/headers`, { const {body} = await got(`${s.url}/headers`, {
body: 'wow', body: 'wow',
json: true, json: true,
headers: { headers: {
@ -77,7 +77,7 @@ test('content-length header is not overriden', async t => {
}); });
test('content-length header disabled for chunked transfer-encoding', async t => { test('content-length header disabled for chunked transfer-encoding', async t => {
let {body} = await got(`${s.url}/headers`, { const {body} = await got(`${s.url}/headers`, {
body: '3\r\nwow\r\n0\r\n', body: '3\r\nwow\r\n0\r\n',
json: true, json: true,
headers: { headers: {
@ -88,7 +88,7 @@ test('content-length header disabled for chunked transfer-encoding', async t =>
}); });
test('object in options.body treated as querystring', async t => { test('object in options.body treated as querystring', async t => {
let {body} = await got(s.url, { const {body} = await got(s.url, {
body: { body: {
such: 'wow' such: 'wow'
} }
@ -97,7 +97,7 @@ test('object in options.body treated as querystring', async t => {
}); });
test('content-type header is not overriden when object in options.body', async t => { test('content-type header is not overriden when object in options.body', async t => {
let {body} = await got(`${s.url}/headers`, { const {body} = await got(`${s.url}/headers`, {
headers: { headers: {
'content-type': 'doge' 'content-type': 'doge'
}, },

6
test/unix-socket.js

@ -4,7 +4,7 @@ import test from 'ava';
import got from '../'; import got from '../';
import {createServer} from './helpers/server'; import {createServer} from './helpers/server';
let socketPath = tempfile('.socket'); const socketPath = tempfile('.socket');
let s; let s;
@ -19,12 +19,12 @@ test.before('setup', async () => {
}); });
test('works', async t => { test('works', async t => {
let url = format('http://unix:%s:%s', socketPath, '/'); const url = format('http://unix:%s:%s', socketPath, '/');
t.is((await got(url)).body, 'ok'); t.is((await got(url)).body, 'ok');
}); });
test('protocol-less works', async t => { test('protocol-less works', async t => {
let url = format('unix:%s:%s', socketPath, '/'); const url = format('unix:%s:%s', socketPath, '/');
t.is((await got(url)).body, 'ok'); t.is((await got(url)).body, 'ok');
}); });

Loading…
Cancel
Save