mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2024-11-10 01:02:30 +01:00
getSearchSegments tests
This commit is contained in:
parent
d163b1d436
commit
67eb165b53
2 changed files with 109 additions and 0 deletions
|
@ -80,6 +80,67 @@ describe("getSearchSegments", () => {
|
|||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to filter by category with categories string", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "searchTest0", categories: `["selfpromo"]` } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = res.data;
|
||||
const segments = data.segments;
|
||||
assert.strictEqual(data.segmentCount, 1);
|
||||
assert.strictEqual(data.page, 0);
|
||||
assert.strictEqual(segments[0].UUID, "search-downvote");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to filter by category with categories array", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "searchTest0", category: ["selfpromo"] } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = res.data;
|
||||
const segments = data.segments;
|
||||
assert.strictEqual(data.segmentCount, 1);
|
||||
assert.strictEqual(data.page, 0);
|
||||
assert.strictEqual(segments[0].UUID, "search-downvote");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to filter by category with actionTypes JSON", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "searchTest5", actionTypes: `["mute"]` } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = res.data;
|
||||
assert.strictEqual(data.segmentCount, 1);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to filter by category with actionType array", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "searchTest5", actionType: ["mute"] } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = res.data;
|
||||
assert.strictEqual(data.segmentCount, 1);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to filter by category with actionType string", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "searchTest5", actionType: "mute" } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 200);
|
||||
const data = res.data;
|
||||
assert.strictEqual(data.segmentCount, 1);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should be able to filter by lock status", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "searchTest0", locked: false } })
|
||||
.then(res => {
|
||||
|
|
48
test/cases/getSearchSegments4xx.ts
Normal file
48
test/cases/getSearchSegments4xx.ts
Normal file
|
@ -0,0 +1,48 @@
|
|||
import { client } from "../utils/httpClient";
|
||||
import assert from "assert";
|
||||
|
||||
describe("getSearchSegments 4xx", () => {
|
||||
const endpoint = "/api/searchSegments";
|
||||
|
||||
it("Should return 400 if no videoID", (done) => {
|
||||
client.get(endpoint, { params: {} })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 400);
|
||||
const data = res.data;
|
||||
assert.strictEqual(data, "videoID not specified");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should return 400 if invalid categories", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "nullVideo", categories: 3 } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 400);
|
||||
const data = res.data;
|
||||
assert.strictEqual(data, "Categories parameter does not match format requirements.");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should return 400 if invalid actionTypes", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "nullVideo", actionTypes: 3 } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 400);
|
||||
const data = res.data;
|
||||
assert.strictEqual(data, "actionTypes parameter does not match format requirements.");
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
|
||||
it("Should return 404 if no segments", (done) => {
|
||||
client.get(endpoint, { params: { videoID: "nullVideo", actionType: "chapter" } })
|
||||
.then(res => {
|
||||
assert.strictEqual(res.status, 404);
|
||||
done();
|
||||
})
|
||||
.catch(err => done(err));
|
||||
});
|
||||
});
|
Loading…
Reference in a new issue