mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-08 12:37:00 +03:00
split postSkipSegments into stubbed 400
This commit is contained in:
@@ -22,6 +22,7 @@ describe("postSkipSegments 400 - missing params", () => {
|
|||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return 400 for missing params (JSON method) 2", (done) => {
|
it("Should return 400 for missing params (JSON method) 2", (done) => {
|
||||||
postSkipSegmentJSON({
|
postSkipSegmentJSON({
|
||||||
userID,
|
userID,
|
||||||
@@ -33,6 +34,7 @@ describe("postSkipSegments 400 - missing params", () => {
|
|||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
it("Should return 400 for missing params (JSON method) 3", (done) => {
|
it("Should return 400 for missing params (JSON method) 3", (done) => {
|
||||||
postSkipSegmentJSON({
|
postSkipSegmentJSON({
|
||||||
userID,
|
userID,
|
||||||
@@ -110,6 +112,20 @@ describe("postSkipSegments 400 - missing params", () => {
|
|||||||
})
|
})
|
||||||
.catch(err => done(err));
|
.catch(err => done(err));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("Should return 400 if no segments provided", (done) => {
|
||||||
|
postSkipSegmentJSON({
|
||||||
|
videoID,
|
||||||
|
segments: [],
|
||||||
|
category: "sponsor",
|
||||||
|
userID
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(err => done(err));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("postSkipSegments 400 - Chapters", () => {
|
describe("postSkipSegments 400 - Chapters", () => {
|
||||||
|
|||||||
32
test/cases/postSkipSegments400Stub.ts
Normal file
32
test/cases/postSkipSegments400Stub.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import assert from "assert";
|
||||||
|
import { postSkipSegmentParam } from "./postSkipSegments";
|
||||||
|
import { config } from "../../src/config";
|
||||||
|
import sinon from "sinon";
|
||||||
|
|
||||||
|
const videoID = "postSkipSegments-404-video";
|
||||||
|
|
||||||
|
describe("postSkipSegments 400 - stubbed config", () => {
|
||||||
|
const USERID_LIMIT = 30;
|
||||||
|
before(() => {
|
||||||
|
sinon.stub(config, "minUserIDLength").value(USERID_LIMIT);
|
||||||
|
});
|
||||||
|
after(() => {
|
||||||
|
sinon.restore();
|
||||||
|
});
|
||||||
|
|
||||||
|
it("Should return 400 if userID is too short", (done) => {
|
||||||
|
const userID = "a".repeat(USERID_LIMIT - 10);
|
||||||
|
postSkipSegmentParam({
|
||||||
|
videoID,
|
||||||
|
startTime: 1,
|
||||||
|
endTime: 5,
|
||||||
|
category: "sponsor",
|
||||||
|
userID
|
||||||
|
})
|
||||||
|
.then(res => {
|
||||||
|
assert.strictEqual(res.status, 400);
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(err => done(err));
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user