Fix curl export with multi-line body

This commit is contained in:
Gregory Schier
2024-05-14 00:05:54 -07:00
parent 5a2d510d07
commit 31147475f3
3 changed files with 42 additions and 1 deletions

View File

@@ -80,6 +80,26 @@ describe('exporter-curl', () => {
);
});
test('Exports multi-line JSON body', () => {
expect(
pluginHookExport({
url: 'https://yaak.app',
method: 'POST',
bodyType: 'application/json',
body: {
text: `{"foo":"bar",\n"baz":"qux"}`,
},
headers: [{ name: 'Content-Type', value: 'application/json' }],
}),
).toEqual(
[
`curl -X POST 'https://yaak.app'`,
`--header 'Content-Type: application/json'`,
`--data-raw $'{"foo":"bar",\n"baz":"qux"}'`,
].join(` \\\n `),
);
});
test('Exports headers', () => {
expect(
pluginHookExport({