Support new GraphQL body type in curl export

This commit is contained in:
Gregory Schier
2024-10-22 07:26:16 -07:00
parent 9d24aefba1
commit d91e60f7e0
2 changed files with 23 additions and 4 deletions

View File

@@ -38,6 +38,22 @@ describe('exporter-curl', () => {
);
});
test('Exports POST with GraphQL data', async () => {
expect(
await pluginHookExport(ctx, {
url: 'https://yaak.app',
method: 'POST',
bodyType: 'graphql',
body: {
query : '{foo,bar}',
variables: {a: 'aaa', b: 'bbb'},
},
}),
).toEqual(
[`curl -X POST 'https://yaak.app'`, `--data-raw '{"query":"{foo,bar}","variables":{"a":"aaa","b":"bbb"}}'`].join(` \\\n `),
);
});
test('Exports PUT with multipart form', async () => {
expect(
await pluginHookExport(ctx, {
@@ -78,7 +94,7 @@ describe('exporter-curl', () => {
[
`curl -X POST 'https://yaak.app'`,
`--header 'Content-Type: application/json'`,
`--data-raw $'{"foo":"bar\\'s"}'`,
`--data-raw '{"foo":"bar\\'s"}'`,
].join(` \\\n `),
);
});
@@ -98,7 +114,7 @@ describe('exporter-curl', () => {
[
`curl -X POST 'https://yaak.app'`,
`--header 'Content-Type: application/json'`,
`--data-raw $'{"foo":"bar",\n"baz":"qux"}'`,
`--data-raw '{"foo":"bar",\n"baz":"qux"}'`,
].join(` \\\n `),
);
});