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": {
"esnext": true,
"rules": {
"prefer-const": 0
}
"esnext": true
}
}

2
test/gzip.js

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

10
test/headers.js

@ -16,12 +16,12 @@ test.before('setup', async () => {
});
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');
});
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');
});
@ -34,17 +34,17 @@ test('accept header with json option', 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}`);
});
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');
});
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');
});

2
test/http.js

@ -52,7 +52,7 @@ test('error with code', 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));
});

8
test/https.js

@ -10,15 +10,15 @@ let cert;
let caRootKey;
let caRootCert;
let pemP = pify(pem, Promise);
const pemP = pify(pem, Promise);
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;
caRootCert = caKeys.certificate;
let keys = await pemP.createCertificate({
const keys = await pemP.createCertificate({
serviceCertificate: caRootCert,
serviceKey: caRootKey,
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 => {
let {body} = await got(s.url, {
const {body} = await got(s.url, {
strictSSL: true,
ca: caRootCert,
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 => {
let {body} = await got(`${s.url}/204`, {json: true});
const {body} = await got(`${s.url}/204`, {json: true});
t.is(body, '');
});

24
test/post.js

@ -25,48 +25,48 @@ test.before('setup', async () => {
});
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(headers.method, 'GET');
});
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');
});
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');
});
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');
});
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, '');
});
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');
});
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');
});
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);
});
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',
json: true,
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 => {
let {body} = await got(`${s.url}/headers`, {
const {body} = await got(`${s.url}/headers`, {
body: '3\r\nwow\r\n0\r\n',
json: true,
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 => {
let {body} = await got(s.url, {
const {body} = await got(s.url, {
body: {
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 => {
let {body} = await got(`${s.url}/headers`, {
const {body} = await got(`${s.url}/headers`, {
headers: {
'content-type': 'doge'
},

6
test/unix-socket.js

@ -4,7 +4,7 @@ import test from 'ava';
import got from '../';
import {createServer} from './helpers/server';
let socketPath = tempfile('.socket');
const socketPath = tempfile('.socket');
let s;
@ -19,12 +19,12 @@ test.before('setup', async () => {
});
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');
});
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');
});

Loading…
Cancel
Save