mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-07 12:07:07 +03:00
Add another warning test
This commit is contained in:
@@ -30,7 +30,7 @@ export async function postWarning(req: Request, res: Response): Promise<Response
|
|||||||
const enabled: boolean = req.body.enabled ?? true;
|
const enabled: boolean = req.body.enabled ?? true;
|
||||||
const reason: string = req.body.reason ?? "";
|
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}.`);
|
Logger.warn(`Permission violation: User ${issuerUserID} attempted to warn user ${userID}.`);
|
||||||
return res.status(403).json({ "message": "Not a VIP" });
|
return res.status(403).json({ "message": "Not a VIP" });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,4 +137,22 @@ describe("postWarning", () => {
|
|||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.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));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user