forked from Kong/httpsnippet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.test.ts
More file actions
151 lines (150 loc) · 3.79 KB
/
Copy pathclient.test.ts
File metadata and controls
151 lines (150 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import applicationFormEncoded from '../../../fixtures/requests/application-form-encoded.json';
import applicationJson from '../../../fixtures/requests/application-json.json';
import full from '../../../fixtures/requests/full.json';
import https from '../../../fixtures/requests/https.json';
import nested from '../../../fixtures/requests/nested.json';
import { runCustomFixtures } from '../../../fixtures/runCustomFixtures';
import { Request } from '../../../httpsnippet';
runCustomFixtures({
targetId: 'shell',
clientId: 'curl',
tests: [
{
it: 'should use short options',
input: full as Request,
options: { short: true, indent: false },
expected: 'short-options.sh',
},
{
it: 'should use binary option',
input: full as Request,
options: {
short: true,
indent: false,
binary: true,
},
expected: 'binary-option.sh',
},
{
it: 'should use short globoff option',
input: nested as Request,
options: {
short: true,
indent: false,
globOff: true,
},
expected: 'globoff-option.sh',
},
{
it: 'should use long globoff option',
input: nested as Request,
options: {
indent: false,
globOff: true,
},
expected: 'long-globoff-option.sh',
},
{
it: 'should not de-glob when globoff is false',
input: nested as Request,
options: {
indent: false,
globOff: false,
},
expected: 'dont-deglob.sh',
},
{
it: 'should use --http1.0 for HTTP/1.0',
input: {
method: 'GET',
url: 'http://mockbin.com/request',
httpVersion: 'HTTP/1.0',
} as Request,
options: {
indent: false,
},
expected: 'http10.sh',
},
{
it: 'should use custom indentation',
input: full as Request,
options: {
indent: '@',
},
expected: 'custom-indentation.sh',
},
{
it: 'should url encode the params key',
input: {
...applicationFormEncoded,
postData: {
mimeType: 'application/x-www-form-urlencoded',
params: [
{ name: 'user name', value: 'John Doe' },
{ name: '$filter', value: 'by id' },
],
},
} as Request,
options: {},
expected: 'urlencode.sh',
},
{
it: 'should support insecureSkipVerify',
input: https as Request,
options: {
insecureSkipVerify: true,
},
expected: 'insecure-skip-verify.sh',
},
{
it: 'should send JSON-encoded data with single quotes within a HEREDOC',
input: {
method: 'POST',
url: 'http://mockbin.com/har',
headers: [
{
name: 'content-type',
value: 'application/json',
},
],
postData: {
mimeType: 'application/json',
text: '{"number":1,"string":"f\'oo"}',
},
} as Request,
options: {
prettifyJson: true,
},
expected: 'jsonObj-with-singlequotes.sh',
},
{
it: 'should prettify simple/short JSON if prettifyJson is true',
input: {
url: 'http://mockbin.com/har',
method: 'POST',
headers: [
{
name: 'content-type',
value: 'application/json',
},
],
postData: {
text: '{"foo": "bar"}',
mimeType: 'application/json',
},
} as Request,
options: {
prettifyJson: true,
},
expected: 'prettify-short-json.sh',
},
{
it: 'should prettify complex json if prettifyJson is true',
input: applicationJson as Request,
options: {
prettifyJson: true,
},
expected: 'application-json-prettified.sh',
},
],
});