mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-31 11:56:27 +03:00
Add test for body user agent
This commit is contained in:
@@ -851,7 +851,7 @@ describe("postSkipSegments", () => {
|
|||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
"User-Agent": "MeaBot/5.0"
|
"User-Agent": "com.google.android.youtube/5.0"
|
||||||
},
|
},
|
||||||
body: JSON.stringify({
|
body: JSON.stringify({
|
||||||
userID: "testtesttesttesttesttesttesttesttest",
|
userID: "testtesttesttesttesttesttesttesttest",
|
||||||
@@ -867,34 +867,7 @@ describe("postSkipSegments", () => {
|
|||||||
const row = await db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "userAgent" FROM "sponsorTimes" WHERE "videoID" = ?`, ["userAgent-1"]);
|
const row = await db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "userAgent" FROM "sponsorTimes" WHERE "videoID" = ?`, ["userAgent-1"]);
|
||||||
assert.strictEqual(row.startTime, 0);
|
assert.strictEqual(row.startTime, 0);
|
||||||
assert.strictEqual(row.endTime, 10);
|
assert.strictEqual(row.endTime, 10);
|
||||||
assert.strictEqual(row.userAgent, "MeaBot/5.0");
|
assert.strictEqual(row.userAgent, "Vanced/5.0");
|
||||||
done();
|
|
||||||
})
|
|
||||||
.catch(err => done(err));
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Should be able to submit with custom user-agent 2", (done: Done) => {
|
|
||||||
fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, {
|
|
||||||
method: "POST",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
"User-Agent": "MeaBot"
|
|
||||||
},
|
|
||||||
body: JSON.stringify({
|
|
||||||
userID: "testtesttesttesttesttesttesttesttest",
|
|
||||||
videoID: "userAgent-2",
|
|
||||||
segments: [{
|
|
||||||
segment: [0, 10],
|
|
||||||
category: "sponsor",
|
|
||||||
}],
|
|
||||||
}),
|
|
||||||
})
|
|
||||||
.then(async res => {
|
|
||||||
assert.strictEqual(res.status, 200);
|
|
||||||
const row = await db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "userAgent" FROM "sponsorTimes" WHERE "videoID" = ?`, ["userAgent-2"]);
|
|
||||||
assert.strictEqual(row.startTime, 0);
|
|
||||||
assert.strictEqual(row.endTime, 10);
|
|
||||||
assert.strictEqual(row.userAgent, "MeaBot");
|
|
||||||
done();
|
done();
|
||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
@@ -926,4 +899,31 @@ describe("postSkipSegments", () => {
|
|||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should be able to submit with custom userAgent in body", (done: Done) => {
|
||||||
|
fetch(`${getbaseURL()}/api/postVideoSponsorTimes`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json"
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
userID: "testtesttesttesttesttesttesttesttest",
|
||||||
|
videoID: "userAgent-4",
|
||||||
|
segments: [{
|
||||||
|
segment: [0, 10],
|
||||||
|
category: "sponsor",
|
||||||
|
}],
|
||||||
|
userAgent: "MeaBot/5.0"
|
||||||
|
}),
|
||||||
|
})
|
||||||
|
.then(async res => {
|
||||||
|
assert.strictEqual(res.status, 200);
|
||||||
|
const row = await db.prepare("get", `SELECT "startTime", "endTime", "locked", "category", "userAgent" FROM "sponsorTimes" WHERE "videoID" = ?`, ["userAgent-4"]);
|
||||||
|
assert.strictEqual(row.startTime, 0);
|
||||||
|
assert.strictEqual(row.endTime, 10);
|
||||||
|
assert.strictEqual(row.userAgent, "MeaBot/5.0");
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(err => done(err));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user