Skip to content

Commit 6962366

Browse files
committed
Fix rhttr and parseBody tests
1 parent 05d16e9 commit 6962366

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

codegens/r-httr/test/unit/parseBody.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ describe('parseBody function', function () {
1515
body = collection.items.members[8].request.body,
1616
indentation = ' ',
1717
bodyTrim = false,
18-
expectedBody = 'body = \'{\n "json": "Test-Test"\n}\';\n';
18+
expectedBody = 'body = \'{\n "json": "Test-Test"\n}\';\n\n';
1919
let bodySnippet = parseBody(body, indentation, bodyTrim, 'application/json');
2020
expect(bodySnippet).to.equal(expectedBody);
2121
});
@@ -26,7 +26,7 @@ describe('parseBody function', function () {
2626
body = collection.items.members[8].request.body,
2727
indentation = ' ',
2828
bodyTrim = false,
29-
expectedBody = 'body = \'{\n "json": "Test-Test"\n}\';\n';
29+
expectedBody = 'body = \'{\n "json": "Test-Test"\n}\';\n\n';
3030
let bodySnippet = parseBody(body, indentation, bodyTrim, 'application/json');
3131
expect(bodySnippet).to.equal(expectedBody);
3232
});
@@ -37,7 +37,7 @@ describe('parseBody function', function () {
3737
body = collection.items.members[10].request.body,
3838
indentation = ' ',
3939
bodyTrim = false,
40-
expectedBody = 'body = "<xml>\n\tTest Test\n</xml>"\n';
40+
expectedBody = 'body = "<xml>\n\tTest Test\n</xml>"\n\n';
4141
let bodySnippet = parseBody(body, indentation, bodyTrim, 'application/json');
4242
expect(bodySnippet).to.equal(expectedBody);
4343
});
@@ -53,7 +53,7 @@ describe('parseBody function', function () {
5353
' \'"4" \' = \'d \',\n' +
5454
' \'Special\' = \'!@#$%&*()^_=`~\',\n' +
5555
' \'more\' = \',./\\\';[]}{":?><|\\\\\\\\\'\n' +
56-
')\n',
56+
')\n\n',
5757
result = parseBody(body, indentation, bodyTrim, 'application/x-www-form-urlencoded');
5858
expect(result).to.equal(expectedBody);
5959

@@ -72,7 +72,7 @@ describe('parseBody function', function () {
7272
' \'sa\' = \'d\',\n' +
7373
' \'Special \' = \'!@#$%&*()^_+=`~ \',\n' +
7474
' \'more\' = \',./\\\';[]}{":?><|\\\\\\\\\'\n' +
75-
')\n',
75+
')\n\n',
7676
result = parseBody(body, indentation, bodyTrim, 'formdata');
7777
expect(result).to.equal(expectedBody);
7878

@@ -86,7 +86,7 @@ describe('parseBody function', function () {
8686
bodyTrim = false,
8787
expectedBody = 'body = list(\n' +
8888
' \'test-file\' = upload_file(\'/path/to/file\')\n' +
89-
')\n',
89+
')\n\n',
9090
result = parseBody(body, indentation, bodyTrim, 'formdata');
9191
expect(result).to.equal(expectedBody);
9292

@@ -98,7 +98,7 @@ describe('parseBody function', function () {
9898
body = collection.items.members[25].request.body,
9999
indentation = ' ',
100100
bodyTrim = false,
101-
expectedBody = 'body = upload_file(\'<file contents here>\')\n',
101+
expectedBody = 'body = upload_file(\'<file contents here>\')\n\n',
102102
result = parseBody(body, indentation, bodyTrim, 'formdata');
103103
expect(result).to.equal(expectedBody);
104104

@@ -113,7 +113,7 @@ describe('parseBody function', function () {
113113
expectedBody = 'body = \'{"query":"{\\\\n findScenes(\\\\n filter: {per_page: 0}\\\\n ' +
114114
' scene_filter: {is_missing: \\\\"performers\\\\"}){\\\\n count\\\\n scenes' +
115115
' {\\\\n id\\\\n title\\\\n path\\\\n }\\\\n }\\\\n}","variables":' +
116-
'{"variable_key":"variable_value"}}\'\n',
116+
'{"variable_key":"variable_value"}}\'\n\n',
117117
result = parseBody(body, indentation, bodyTrim, 'graphql');
118118
expect(result).to.equal(expectedBody);
119119

codegens/r-httr/test/unit/rHttr.test.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ var expect = require('chai').expect,
99
describe('getSnippetHeaders function', function () {
1010

1111
it('should generate headers declaration snippet', function () {
12-
const expected = 'headers = c(\n \'"1"\' = \'\\\'a\\\'\',\n \'"2"\' = \'"b"\'\n)\n',
12+
const expected = 'headers = c(\n \'"1"\' = \'\\\'a\\\'\',\n \'"2"\' = \'"b"\'\n)\n\n',
1313
res = getSnippetHeaders([{ key: '"1"', value: '\'a\''}, { key: '"2"', value: '"b"'}], ' ');
1414
expect(res).to.equal(expected);
1515
});
@@ -21,7 +21,7 @@ describe('getSnippetHeaders function', function () {
2121
});
2222

2323
it('should generate headers declaration snippet with empty indentation', function () {
24-
const expected = 'headers = c(\n\'"1"\' = \'\\\'a\\\'\',\n\'"2"\' = \'"b"\'\n)\n',
24+
const expected = 'headers = c(\n\'"1"\' = \'\\\'a\\\'\',\n\'"2"\' = \'"b"\'\n)\n\n',
2525
res = getSnippetHeaders([{ key: '"1"', value: '\'a\''}, { key: '"2"', value: '"b"'}], '');
2626
expect(res).to.equal(expected);
2727
});
@@ -32,14 +32,14 @@ describe('getSnippetFromMethod function', function () {
3232

3333
it('should generate postForm snippet with params headers and post style', function () {
3434
const expected = 'res <- VERB("POST", url = "https://postman-echo.com/post", ' +
35-
'body = body, add_headers(headers), encode = \'form\')\n',
35+
'body = body, add_headers(headers), encode = \'form\')\n\n',
3636
res = getSnippetFromMethod('https://postman-echo.com/post', true, true, 'POST', 'urlencoded');
3737
expect(res).to.equal(expected);
3838
});
3939

4040
it('should generate postForm snippet without params with headers and post style', function () {
4141
const expected = 'res <- VERB("POST", url = "https://postman-echo.com/post", ' +
42-
'add_headers(headers), encode = \'form\')\n',
42+
'add_headers(headers), encode = \'form\')\n\n',
4343
res = getSnippetFromMethod(
4444
'https://postman-echo.com/post',
4545
false,
@@ -52,7 +52,7 @@ describe('getSnippetFromMethod function', function () {
5252

5353
it('should generate postForm snippet without params with headers and post style', function () {
5454
const expected = 'res <- VERB("POST", url = "https://postman-echo.com/post", ' +
55-
'add_headers(headers), encode = \'form\', timeout(3))\n',
55+
'add_headers(headers), encode = \'form\', timeout(3))\n\n',
5656
res = getSnippetFromMethod(
5757
'https://postman-echo.com/post',
5858
false,
@@ -66,19 +66,19 @@ describe('getSnippetFromMethod function', function () {
6666

6767
it('should generate GET snippet with params headers', function () {
6868
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers", ' +
69-
'add_headers(headers))\n',
69+
'add_headers(headers))\n\n',
7070
res = getSnippetFromMethod('https://postman-echo.com/headers', false, true, 'GET', undefined, undefined);
7171
expect(res).to.equal(expected);
7272
});
7373

7474
it('should generate GET snippet without headers', function () {
75-
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers")\n',
75+
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers")\n\n',
7676
res = getSnippetFromMethod('https://postman-echo.com/headers', false, false, 'GET', undefined, undefined);
7777
expect(res).to.equal(expected);
7878
});
7979

8080
it('should generate GET snippet with timeout', function () {
81-
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers", timeout(3))\n',
81+
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers", timeout(3))\n\n',
8282
res = getSnippetFromMethod('https://postman-echo.com/headers', false, false, 'GET', undefined, 3);
8383
expect(res).to.equal(expected);
8484
});
@@ -88,7 +88,7 @@ describe('getSnippetFromMethod function', function () {
8888
describe('getSnippetRequest function', function () {
8989

9090
it('should generate snippet method GET with headers', function () {
91-
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers", add_headers(headers))\n',
91+
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers", add_headers(headers))\n\n',
9292
res = getSnippetRequest({
9393
url: 'https://postman-echo.com/headers',
9494
method: 'GET',
@@ -99,7 +99,7 @@ describe('getSnippetRequest function', function () {
9999
});
100100

101101
it('should generate snippet method GET without headers', function () {
102-
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers")\n',
102+
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers")\n\n',
103103
res = getSnippetRequest({
104104
url: 'https://postman-echo.com/headers',
105105
method: 'GET',
@@ -110,7 +110,7 @@ describe('getSnippetRequest function', function () {
110110
});
111111

112112
it('should generate snippet method GET without headers and timeout', function () {
113-
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers", timeout(3))\n',
113+
const expected = 'res <- VERB("GET", url = "https://postman-echo.com/headers", timeout(3))\n\n',
114114
res = getSnippetRequest({
115115
url: 'https://postman-echo.com/headers',
116116
method: 'GET',
@@ -122,7 +122,7 @@ describe('getSnippetRequest function', function () {
122122
});
123123

124124
it('should generate snippet method HEAD', function () {
125-
const expected = 'res <- VERB("HEAD", url = "https://postman-echo.com/headers")\n',
125+
const expected = 'res <- VERB("HEAD", url = "https://postman-echo.com/headers")\n\n',
126126
res = getSnippetRequest({
127127
url: 'https://postman-echo.com/headers',
128128
method: 'HEAD',

0 commit comments

Comments
 (0)