forked from postmanlabs/httpsnippet-fsless
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcurl.js
More file actions
35 lines (27 loc) · 1.26 KB
/
curl.js
File metadata and controls
35 lines (27 loc) · 1.26 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
/* global it */
'use strict'
require('should')
module.exports = function (HTTPSnippet, fixtures) {
it('should use short options', function () {
var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', {
short: true,
indent: false
})
result.should.be.a.String
result.should.eql("curl -X POST 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' -H 'accept: application/json' -H 'content-type: application/x-www-form-urlencoded' -b 'foo=bar; bar=baz' -d foo=bar")
})
it('should use --http1.0 for HTTP/1.0', function () {
var result = new HTTPSnippet(fixtures.curl.http1).convert('shell', 'curl', {
indent: false
})
result.should.be.a.String
result.should.eql('curl --request GET --url http://mockbin.com/request --http1.0')
})
it('should use custom indentation', function () {
var result = new HTTPSnippet(fixtures.requests.full).convert('shell', 'curl', {
indent: '@'
})
result.should.be.a.String
result.replace(/\\\n/g, '').should.eql("curl --request POST @--url 'http://mockbin.com/har?foo=bar&foo=baz&baz=abc&key=value' @--header 'accept: application/json' @--header 'content-type: application/x-www-form-urlencoded' @--cookie 'foo=bar; bar=baz' @--data foo=bar")
})
}