Skip to content

Commit

Permalink
Create no-schema.js
Browse files Browse the repository at this point in the history
  • Loading branch information
FlameWolf authored Apr 8, 2024
1 parent 2fc1d9b commit 853f037
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/no-schema.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"use strict";

const setup = require("./setup");
const tap = require("tap");
const { Readable } = require("stream");
const { once } = require("events");

tap.test("should parse fields as strings when there is no schema", async t => {
const instance = require("fastify").fastify();
t.teardown(async () => {
await instance.close();
});
try {
instance.addHook("onResponse", async (request, reply) => {
const requestBody = request.body;
t.type(requestBody.name, "string");
t.ok(requestBody.avatar.stream instanceof Readable);
t.type(requestBody.age, "string");
t.type(requestBody.address, "string");
t.equal(reply.statusCode, 200);
});
const req = await setup(instance, undefined, false);
const [res] = await once(req, "response");
res.resume();
} catch (err) {
console.log(err);
}
});

0 comments on commit 853f037

Please sign in to comment.