Skip to content

Commit cbd5bb9

Browse files
committed
test: createMediaType examples parameter
1 parent 8b30f73 commit cbd5bb9

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/core/createMediaType.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ import type { SchemaObject } from "@omer-x/openapi-types/schema";
55
describe("createMediaType", () => {
66
const mockSchema: SchemaObject = { type: "string" };
77
const mockExample = "example text";
8+
const mockExamples = {
9+
"Example-1": {
10+
value: "Example 1",
11+
description: "1st Example",
12+
},
13+
"Example-2": {
14+
value: "Example 2",
15+
description: "2nd Example",
16+
},
17+
"Example-3": {
18+
value: "Example 3",
19+
description: "3rd Example",
20+
},
21+
};
822

923
it("should create a MediaTypeObject with only the schema", () => {
1024
expect(createMediaType(mockSchema)).toStrictEqual({
@@ -18,4 +32,24 @@ describe("createMediaType", () => {
1832
example: mockExample,
1933
});
2034
});
35+
36+
it("should create a MediaTypeObject with schema and example when example is provided", () => {
37+
expect(createMediaType(mockSchema, undefined, mockExamples)).toStrictEqual({
38+
schema: mockSchema,
39+
examples: {
40+
"Example-1": {
41+
value: "Example 1",
42+
description: "1st Example",
43+
},
44+
"Example-2": {
45+
value: "Example 2",
46+
description: "2nd Example",
47+
},
48+
"Example-3": {
49+
value: "Example 3",
50+
description: "3rd Example",
51+
},
52+
},
53+
});
54+
});
2155
});

0 commit comments

Comments
 (0)