mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-12 14:37:17 +03:00
finish tests and remove extra console.logs
This commit is contained in:
@@ -56,6 +56,7 @@ describe("voteOnSponsorTime", () => {
|
||||
await db.prepare("run", insertSponsorTimeQuery, ["category-change-test-1", 8, 12, 0, 1, "category-change-uuid-6", categoryChangeUserHash, 0, 50, "intro", 0, 0]);
|
||||
await db.prepare("run", insertSponsorTimeQuery, ["category-change-test-1", 9, 14, 0, 0, "category-change-uuid-7", categoryChangeUserHash, 0, 50, "intro", 0, 0]);
|
||||
await db.prepare("run", insertSponsorTimeQuery, ["category-change-test-1", 7, 12, 0, 1, "category-change-uuid-8", categoryChangeUserHash, 0, 50, "intro", 0, 0]);
|
||||
await db.prepare("run", insertSponsorTimeQuery, ["duration-update", 1, 10, 0, 0, "duration-update-uuid-1", "testman", 0, 0, "intro", 0, 0]);
|
||||
|
||||
const insertWarningQuery = 'INSERT INTO "warnings" ("userID", "issueTime", "issuerUserID", "enabled") VALUES(?, ?, ?, ?)';
|
||||
await db.prepare("run", insertWarningQuery, [warnUser01Hash, now, warnVip01Hash, 1]);
|
||||
@@ -98,6 +99,7 @@ describe("voteOnSponsorTime", () => {
|
||||
|
||||
const getSegmentVotes = (UUID: string) => db.prepare("get", `SELECT "votes" FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]);
|
||||
const getSegmentCategory = (UUID: string) => db.prepare("get", `SELECT "category" FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]);
|
||||
const getVideoDuration = (UUID: string) => db.prepare("get", `SELECT "videoDuration" FROM "sponsorTimes" WHERE "UUID" = ?`, [UUID]).then(row => row.videoDuration);
|
||||
|
||||
it("Should be able to upvote a segment", (done) => {
|
||||
const UUID = "vote-uuid-0";
|
||||
@@ -299,7 +301,6 @@ describe("voteOnSponsorTime", () => {
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const row = await getSegmentCategory(UUID);
|
||||
console.log(row.category);
|
||||
assert.strictEqual(row.category, category);
|
||||
done();
|
||||
})
|
||||
@@ -314,7 +315,6 @@ describe("voteOnSponsorTime", () => {
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const row = await getSegmentCategory(UUID);
|
||||
console.log(row.category);
|
||||
assert.strictEqual(row.category, "intro");
|
||||
done();
|
||||
})
|
||||
@@ -348,7 +348,7 @@ describe("voteOnSponsorTime", () => {
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
|
||||
it("Vip should be able to vote for a category and it should immediately change (segment unlocked, nextCatgeory unlocked, Vip)", (done) => {
|
||||
const userID = vipUser;
|
||||
const UUID = "category-change-uuid-5";
|
||||
@@ -404,7 +404,7 @@ describe("voteOnSponsorTime", () => {
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
|
||||
it("Should not be able to category-vote on an invalid UUID submission", (done) => {
|
||||
const UUID = "invalid-uuid";
|
||||
postVoteCategory("randomID3", UUID, "intro")
|
||||
@@ -564,4 +564,15 @@ describe("voteOnSponsorTime", () => {
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to update stored videoDuration with VIP upvote", (done) => {
|
||||
const UUID = "duration-update-uuid-1";
|
||||
postVote(vipUser, UUID, 1)
|
||||
.then(async res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const newDuration = await getVideoDuration(UUID);
|
||||
assert.strictEqual(newDuration, 500);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user