Skip to content

Commit 9705397

Browse files
committed
test: createMediaType function
1 parent ef17461 commit 9705397

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

src/core/createMediaType.test.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { describe, expect, it } from "@jest/globals";
2+
import createMediaType from "./createMediaType";
3+
import type { SchemaObject } from "@omer-x/openapi-types/schema";
4+
5+
describe("createMediaType", () => {
6+
const mockSchema: SchemaObject = { type: "string" };
7+
const mockExample = "example text";
8+
9+
it("should create a MediaTypeObject with only the schema", () => {
10+
expect(createMediaType(mockSchema)).toStrictEqual({
11+
schema: mockSchema,
12+
});
13+
});
14+
15+
it("should create a MediaTypeObject with schema and example when example is provided", () => {
16+
expect(createMediaType(mockSchema, mockExample)).toStrictEqual({
17+
schema: mockSchema,
18+
example: mockExample,
19+
});
20+
});
21+
});

0 commit comments

Comments
 (0)