SponsorBlockServer/test/cases/postSkipSegments400Stub.ts
2023-02-21 20:09:13 -05:00

32 lines
890 B
TypeScript

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));
});
});