Skip to content

Commit 8ea7e13

Browse files
authored
chore: minor cleanup (Kong#286)
1 parent 735e69a commit 8ea7e13

20 files changed

Lines changed: 97 additions & 60 deletions

src/httpsnippet.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('hTTPSnippet', () => {
126126
});
127127
});
128128

129-
it('should fix the `path` propety of uriObj to match queryString', () => {
129+
it('should fix the `path` property of uriObj to match queryString', () => {
130130
const snippet = new HTTPSnippet(query as Request);
131131
const request = snippet.requests[0];
132132

@@ -200,7 +200,7 @@ describe('hTTPSnippet', () => {
200200
});
201201

202202
describe('url', () => {
203-
it('shoudl modify the original url to strip query string', () => {
203+
it('should modify the original url to strip query string', () => {
204204
const snippet = new HTTPSnippet(query as Request);
205205
const request = snippet.requests[0];
206206

src/targets/node/fetch/client.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export const fetch: Client = {
9797
// construct cookies argument
9898
if (cookies.length) {
9999
const cookiesString = cookies
100-
.map(cookie => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}; `)
101-
.join('');
100+
.map(cookie => `${encodeURIComponent(cookie.name)}=${encodeURIComponent(cookie.value)}`)
101+
.join('; ');
102102
if (reqOpts.headers) {
103103
reqOpts.headers.cookie = cookiesString;
104104
} else {
@@ -107,16 +107,15 @@ export const fetch: Client = {
107107
}
108108
}
109109
blank();
110-
push(`let url = '${url}';`);
111-
blank();
110+
push(`const url = '${url}';`);
112111

113112
// If we ultimately don't have any headers to send then we shouldn't add an empty object into the request options.
114113
if (reqOpts.headers && !Object.keys(reqOpts.headers).length) {
115114
delete reqOpts.headers;
116115
}
117116

118117
const stringifiedOptions = stringifyObject(reqOpts, { indent: ' ', inlineCharacterLimit: 80 });
119-
push(`let options = ${stringifiedOptions};`);
118+
push(`const options = ${stringifiedOptions};`);
120119
blank();
121120

122121
if (includeFS) {

src/targets/node/fetch/fixtures/application-form-encoded.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,8 @@ const encodedParams = new URLSearchParams();
55
encodedParams.set('foo', 'bar');
66
encodedParams.set('hello', 'world');
77

8-
let url = 'http://mockbin.com/har';
9-
10-
let options = {
8+
const url = 'http://mockbin.com/har';
9+
const options = {
1110
method: 'POST',
1211
headers: {'content-type': 'application/x-www-form-urlencoded'},
1312
body: encodedParams

src/targets/node/fetch/fixtures/application-json.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fetch = require('node-fetch');
22

3-
let url = 'http://mockbin.com/har';
4-
5-
let options = {
3+
const url = 'http://mockbin.com/har';
4+
const options = {
65
method: 'POST',
76
headers: {'content-type': 'application/json'},
87
body: '{"number":1,"string":"f\"oo","arr":[1,2,3],"nested":{"a":"b"},"arr_mix":[1,"a",{"arr_mix_nested":{}}],"boolean":false}'

src/targets/node/fetch/fixtures/cookies.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fetch = require('node-fetch');
22

3-
let url = 'http://mockbin.com/har';
4-
5-
let options = {method: 'POST', headers: {cookie: 'foo=bar; bar=baz; '}};
3+
const url = 'http://mockbin.com/har';
4+
const options = {method: 'POST', headers: {cookie: 'foo=bar; bar=baz'}};
65

76
fetch(url, options)
87
.then(res => res.json())

src/targets/node/fetch/fixtures/custom-method.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fetch = require('node-fetch');
22

3-
let url = 'http://mockbin.com/har';
4-
5-
let options = {method: 'PROPFIND'};
3+
const url = 'http://mockbin.com/har';
4+
const options = {method: 'PROPFIND'};
65

76
fetch(url, options)
87
.then(res => res.json())

src/targets/node/fetch/fixtures/full.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@ const encodedParams = new URLSearchParams();
44

55
encodedParams.set('foo', 'bar');
66

7-
let url = 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value';
8-
9-
let options = {
7+
const url = 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value';
8+
const options = {
109
method: 'POST',
1110
headers: {
1211
accept: 'application/json',
1312
'content-type': 'application/x-www-form-urlencoded',
14-
cookie: 'foo=bar; bar=baz; '
13+
cookie: 'foo=bar; bar=baz'
1514
},
1615
body: encodedParams
1716
};

src/targets/node/fetch/fixtures/headers.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fetch = require('node-fetch');
22

3-
let url = 'http://mockbin.com/har';
4-
5-
let options = {
3+
const url = 'http://mockbin.com/har';
4+
const options = {
65
method: 'GET',
76
headers: {accept: 'application/json', 'x-foo': 'Bar', 'x-bar': 'Foo'}
87
};

src/targets/node/fetch/fixtures/https.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fetch = require('node-fetch');
22

3-
let url = 'https://mockbin.com/har';
4-
5-
let options = {method: 'GET'};
3+
const url = 'https://mockbin.com/har';
4+
const options = {method: 'GET'};
65

76
fetch(url, options)
87
.then(res => res.json())

src/targets/node/fetch/fixtures/jsonObj-multiline.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
const fetch = require('node-fetch');
22

3-
let url = 'http://mockbin.com/har';
4-
5-
let options = {
3+
const url = 'http://mockbin.com/har';
4+
const options = {
65
method: 'POST',
76
headers: {'content-type': 'application/json'},
87
body: '{"foo":"bar"}'

0 commit comments

Comments
 (0)