Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions src/targets/clojure/clj_http/client.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import type { Request } from '../../..';

import { runCustomFixtures } from '../../../fixtures/runCustomFixtures';

runCustomFixtures({
targetId: 'clojure',
clientId: 'clj_http',
tests: [
{
it: 'should not crash if there is no `postData.text`',
input: {
headers: [
{
name: 'accept',
value: 'application/json',
},
{
name: 'content-type',
value: 'application/json',
},
],
postData: {
mimeType: 'application/json',
},
bodySize: 0,
method: 'POST',
url: 'https://httpbin.org/anything',
httpVersion: 'HTTP/1.1',
} as Request,
options: {},
expected: 'should-not-crash.clj',
},
],
});
4 changes: 3 additions & 1 deletion src/targets/clojure/clj_http/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ const jsType = (input?: any) => {
};

const objEmpty = (input?: any) => {
if (jsType(input) === 'object') {
if (input === undefined) {
return true;
} else if (jsType(input) === 'object') {
return Object.keys(input).length === 0;
}
return false;
Expand Down
4 changes: 4 additions & 0 deletions src/targets/clojure/clj_http/fixtures/should-not-crash.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
(require '[clj-http.client :as client])

(client/post "https://httpbin.org/anything" {:content-type :json
:accept :json})