Permit zero-length strings for about me

This commit is contained in:
Bottersnike
2022-10-02 23:51:25 +01:00
parent 131e0f2dc9
commit 7e8315e7a6
2 changed files with 15 additions and 1 deletions
@@ -34,7 +34,7 @@ function AboutMeCard({ reqUser }: Props) {
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({ about: content.length === 0 ? null : content }),
body: JSON.stringify({ about: content }),
},
true,
true
@@ -120,6 +120,20 @@ t.test("PATCH /api/v1/users/:userID", async (t) => {
t.end();
});
t.test("Shouldn't allow empty strings for about me.", async (t) => {
const res = await mockApi.patch("/api/v1/users/1").set("Cookie", cookie).send({
about: "",
});
t.equal(res.statusCode, 200);
const dbUser = await db.users.findOne({ id: 1 });
t.equal(dbUser?.about, "");
t.end();
});
t.test("Shouldn't allow about me to be set to null.", async (t) => {
const res = await mockApi.patch("/api/v1/users/1").set("Cookie", cookie).send({
about: null,