getSearchSegments tests

This commit is contained in:
Michael C 2022-09-30 22:58:37 -04:00
parent d163b1d436
commit 67eb165b53
No known key found for this signature in database
GPG key ID: FFB04FB3B878B7B4
2 changed files with 109 additions and 0 deletions

View file

@ -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 => {

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