mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 09:07:47 +01:00
getUserInfo and free chapters tests
This commit is contained in:
parent
67eb165b53
commit
95dd36a782
2 changed files with 66 additions and 0 deletions
|
@ -21,6 +21,7 @@ describe("getUserInfo", () => {
|
|||
await db.prepare("run", sponsorTimesQuery, ["getUserInfo0", 0, 36000, 2,"uuid000009", getHash("getuserinfo_user_03"), 8, 10, "sponsor", "skip", 0]);
|
||||
await db.prepare("run", sponsorTimesQuery, ["getUserInfo3", 1, 11, 2, "uuid000006", getHash("getuserinfo_user_02"), 6, 10, "sponsor", "skip", 0]);
|
||||
await db.prepare("run", sponsorTimesQuery, ["getUserInfo4", 1, 11, 2, "uuid000010", getHash("getuserinfo_user_04"), 9, 10, "chapter", "chapter", 0]);
|
||||
await db.prepare("run", sponsorTimesQuery, ["getUserInfo5", 1, 11, 2, "uuid000011", getHash("getuserinfo_user_05"), 9, 10, "sponsor", "skip", 0]);
|
||||
|
||||
|
||||
const insertWarningQuery = 'INSERT INTO warnings ("userID", "issueTime", "issuerUserID", "enabled", "reason") VALUES (?, ?, ?, ?, ?)';
|
||||
|
|
65
test/cases/getUserInfoFree.ts
Normal file
65
test/cases/getUserInfoFree.ts
Normal file
|
@ -0,0 +1,65 @@
|
|||
import { db } from "../../src/databases/databases";
|
||||
import { getHash } from "../../src/utils/getHash";
|
||||
import assert from "assert";
|
||||
import { client } from "../utils/httpClient";
|
||||
|
||||
describe("getUserInfo Free Chapters", () => {
|
||||
const endpoint = "/api/userInfo";
|
||||
|
||||
const noQualifyUserID = "getUserInfo-Free-noQualify";
|
||||
const vipQualifyUserID = "getUserInfo-Free-VIP";
|
||||
const repQualifyUserID = "getUserInfo-Free-RepQualify";
|
||||
const oldQualifyUserID = "getUserInfo-Free-OldQualify";
|
||||
const postOldQualify = 1600000000000;
|
||||
|
||||
before(async () => {
|
||||
const sponsorTimesQuery = 'INSERT INTO "sponsorTimes" ("videoID", "startTime", "endTime", "votes", "UUID", "userID", "timeSubmitted", views, category, "actionType", "reputation", "shadowHidden") VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
|
||||
await db.prepare("run", sponsorTimesQuery, ["getUserInfoFree", 1, 2, 0, "uuid-guif-0", getHash(repQualifyUserID), postOldQualify, 0, "sponsor", "skip", 20, 0]);
|
||||
await db.prepare("run", sponsorTimesQuery, ["getUserInfoFree", 1, 2, 0, "uuid-guif-1", getHash(oldQualifyUserID), 0, 0, "sponsor", "skip", 0, 0]); // submit at epoch
|
||||
await db.prepare("run", sponsorTimesQuery, ["getUserInfoFree", 1, 2, 0, "uuid-guif-2", getHash(noQualifyUserID), postOldQualify, 0, "sponsor", "skip", 0, 0]);
|
||||
|
||||
await db.prepare("run", `INSERT INTO "vipUsers" ("userID") VALUES (?)`, [getHash(vipQualifyUserID)]);
|
||||
});
|
||||
|
||||
const getUserInfo = (userID: string) => client.get(endpoint, { params: { userID, value: "freeChaptersAccess" } });
|
||||
|
||||
it("Should not get free access (noQuality)", (done) => {
|
||||
getUserInfo(noQualifyUserID)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
assert.strictEqual(res.data.freeChaptersAccess, false);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should get free access (VIP)", (done) => {
|
||||
getUserInfo(vipQualifyUserID)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
assert.strictEqual(res.data.freeChaptersAccess, true);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should get free access (rep)", (done) => {
|
||||
getUserInfo(repQualifyUserID)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
assert.strictEqual(res.data.freeChaptersAccess, true);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should get free access (old)", (done) => {
|
||||
getUserInfo(oldQualifyUserID)
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
assert.strictEqual(res.data.freeChaptersAccess, true);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue