Skip to content

Commit 67ddce9

Browse files
committed
test: assert operationId, content, and responses individually
1 parent 486a392 commit 67ddce9

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

test/multipart-ajv-file.test.js

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const test = require("node:test");
1212
const filePath = path.join(__dirname, "../README.md");
1313

1414
test("show modify the generated schema", async (t) => {
15-
t.plan(4);
15+
t.plan(6);
1616

1717
const fastify = Fastify({
1818
ajv: {
@@ -82,15 +82,23 @@ test("show modify the generated schema", async (t) => {
8282
// }
8383
// }
8484
// })
85-
const schema =
86-
fastify.swagger().paths["/"].post.requestBody.content["multipart/form-data"]
87-
.schema;
88-
t.assert.deepStrictEqual(schema, {
89-
type: "object",
90-
properties: {
91-
field: { type: "string", format: "binary" },
85+
const post = fastify.swagger().paths["/"].post;
86+
t.assert.strictEqual(post.operationId, "test");
87+
// requestBody.required is not asserted because @fastify/swagger v9.7.0
88+
// introduced it (fastify/fastify-swagger#903), making it version-dependent.
89+
t.assert.deepStrictEqual(post.requestBody.content, {
90+
"multipart/form-data": {
91+
schema: {
92+
type: "object",
93+
properties: {
94+
field: { type: "string", format: "binary" },
95+
},
96+
},
9297
},
9398
});
99+
t.assert.deepStrictEqual(post.responses, {
100+
200: { description: "Default Response" },
101+
});
94102

95103
await fastify.listen({ port: 0 });
96104

0 commit comments

Comments
 (0)