Skip to content

Commit

Permalink
snapshot test
Browse files Browse the repository at this point in the history
  • Loading branch information
fern-support committed Jan 30, 2025
1 parent 2ddcf15 commit 82730c0
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions packages/fern-docs/cache/__tests__/ApiDefinitionLoader.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import {
convertToCurl,
toSnippetHttpRequest,
} from "@fern-api/fdr-sdk/api-definition";

describe("curl snippet generation", () => {
it("generates correct curl snippet", () => {
const endpoint: EndpointDefinition = {
id: { EndpointId: undefined },
namespace: [],
displayName: "Test Endpoint",
operationId: "testEndpoint",
method: "POST",
path: [{ type: "literal", value: "test" }],
requests: [
{
body: {
type: "json",
shape: {
type: "object",
properties: {
foo: { type: "string" },
},
},
},
},
],
};

const example: ExampleEndpointCall = {
path: "/test",
responseStatusCode: 200,
name: "Test Example",
pathParameters: {},
queryParameters: {},
headers: {},
requestBody: {
type: "json",
value: { foo: "bar" },
},
responseBody: undefined,
snippets: {},
};

const curlCode = convertToCurl(
toSnippetHttpRequest(endpoint, example, undefined),
{ usesApplicationJsonInFormDataValue: false }
);

expect(curlCode).toMatchInlineSnapshot(`
"curl -X POST /test \\
-H "Content-Type: application/json" \\
-d '{
"foo": "bar"
}'"
`);
});
});

0 comments on commit 82730c0

Please sign in to comment.