Add another warning test

This commit is contained in:
Ajay
2022-07-21 14:19:41 -04:00
parent ddb73af515
commit 603bad4967
2 changed files with 19 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ export async function postWarning(req: Request, res: Response): Promise<Response
const enabled: boolean = req.body.enabled ?? true;
const reason: string = req.body.reason ?? "";
if ((!issuerUserID && enabled) ||(issuerUserID && !await isUserVIP(issuerUserID))) {
if ((!issuerUserID && enabled) || (issuerUserID && !await isUserVIP(issuerUserID))) {
Logger.warn(`Permission violation: User ${issuerUserID} attempted to warn user ${userID}.`);
return res.status(403).json({ "message": "Not a VIP" });
}

View File

@@ -137,4 +137,22 @@ describe("postWarning", () => {
})
.catch(err => done(err));
});
it("Should be able to add your own warning", (done) => {
const json = {
userID: "warning-0"
};
client.post(endpoint, json)
.then(async res => {
assert.strictEqual(res.status, 403);
const data = await getWarning(warnedUser);
const expected = {
enabled: 0
};
assert.ok(partialDeepEquals(data, expected));
done();
})
.catch(err => done(err));
});
});