object-curly-spacing

This commit is contained in:
Michael C
2021-09-22 18:52:35 -04:00
parent 5dcc90b31a
commit a028eaa41a
85 changed files with 406 additions and 405 deletions

View File

@@ -1,6 +1,6 @@
import assert from "assert";
import {db, privateDB} from "../../src/databases/databases";
import { db, privateDB } from "../../src/databases/databases";
describe("dbUpgrade", () => {
it("Should update the database version when starting the application", async () => {

View File

@@ -1,4 +1,4 @@
import {strictEqual, ok} from "assert";
import { strictEqual, ok } from "assert";
import { db } from "../../src/databases/databases";
import { archiveDownvoteSegment } from "../../src/cronjob/downvoteSegmentArchiveJob";
import { DBSegment } from "../../src/types/segments.model";

View File

@@ -1,5 +1,5 @@
import {getHash} from "../../src/utils/getHash";
import {notStrictEqual, strictEqual} from "assert";
import { getHash } from "../../src/utils/getHash";
import { notStrictEqual, strictEqual } from "assert";
describe("getHash", () => {
it("Should not output the input string", () => {

View File

@@ -1,12 +1,12 @@
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { client } from "../utils/httpClient";
import assert from "assert";
const VIPUser = "isUserVIPVIP";
const normalUser = "isUserVIPNormal";
const endpoint = "/api/isUserVIP";
const vipUserRequest = (userID: string) => client.get(endpoint, { params: { userID }});
const vipUserRequest = (userID: string) => client.get(endpoint, { params: { userID } });
describe("getIsUserVIP", () => {
before(() => {

View File

@@ -1,5 +1,5 @@
import {getHash} from "../../src/utils/getHash";
import {db} from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import assert from "assert";
import { client } from "../utils/httpClient";
const endpoint = "/api/lockCategories";

View File

@@ -1,5 +1,5 @@
import {getHash} from "../../src/utils/getHash";
import {db} from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import assert from "assert";
import { client } from "../utils/httpClient";

View File

@@ -1,8 +1,8 @@
import fetch from "node-fetch";
import {Done} from "../utils/utils";
import { Done } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import {getHash} from "../../src/utils/getHash";
import {db} from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import assert from "assert";
const endpoint = `${getbaseURL()}/api/lockReason`;
@@ -63,7 +63,7 @@ describe("getLockReason", () => {
const data = await res.json();
const expected = [
{ category: "sponsor", locked: 1, reason: "sponsor-reason" },
{ category: "intro", locked: 0, reason: ""}
{ category: "intro", locked: 0, reason: "" }
];
assert.deepStrictEqual(data, expected);
done();

View File

@@ -1,6 +1,6 @@
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import {deepStrictEqual} from "assert";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { deepStrictEqual } from "assert";
import { client } from "../utils/httpClient";
const endpoint = "/api/getSavedTimeForUser";
@@ -14,7 +14,7 @@ describe("getSavedTimeForUser", () => {
});
it("Should be able to get a 200", (done) => {
client.get(endpoint, { params: { userID: user1 }})
client.get(endpoint, { params: { userID: user1 } })
.then(res => {
// (end-start)*minute * views
const savedMinutes = ((11-1)/60) * 50;

View File

@@ -1,4 +1,4 @@
import {db} from "../../src/databases/databases";
import { db } from "../../src/databases/databases";
import { client } from "../utils/httpClient";
import assert from "assert";
@@ -33,7 +33,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to show all segments under searchTest0", (done) => {
client.get(endpoint, { params: { videoID: "searchTest0" }})
client.get(endpoint, { params: { videoID: "searchTest0" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -51,7 +51,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter by category", (done) => {
client.get(endpoint, { params: { videoID: "searchTest0", category: "selfpromo" }})
client.get(endpoint, { params: { videoID: "searchTest0", category: "selfpromo" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -65,7 +65,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter by category", (done) => {
client.get(endpoint, { params: { videoID: "searchTest0", category: "selfpromo" }})
client.get(endpoint, { params: { videoID: "searchTest0", category: "selfpromo" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -79,7 +79,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter by lock status", (done) => {
client.get(endpoint, { params: { videoID: "searchTest0", locked: false }})
client.get(endpoint, { params: { videoID: "searchTest0", locked: false } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -96,7 +96,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter by hide status", (done) => {
client.get(endpoint, { params: { videoID: "searchTest0", hidden: false }})
client.get(endpoint, { params: { videoID: "searchTest0", hidden: false } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -113,7 +113,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter by ignored status", (done) => {
client.get(endpoint, { params: { videoID: "searchTest0", ignored: false }})
client.get(endpoint, { params: { videoID: "searchTest0", ignored: false } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -129,7 +129,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter segments by min views", (done) => {
client.get(endpoint, { params: { videoID: "searchTest1", minViews: 6 }})
client.get(endpoint, { params: { videoID: "searchTest1", minViews: 6 } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -143,7 +143,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter segments by max views", (done) => {
client.get(endpoint, { params: { videoID: "searchTest1", maxViews: 10 }})
client.get(endpoint, { params: { videoID: "searchTest1", maxViews: 10 } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -157,7 +157,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter segments by min and max views", (done) => {
client.get(endpoint, { params: { videoID: "searchTest1", maxViews: 10, minViews: 1 }})
client.get(endpoint, { params: { videoID: "searchTest1", maxViews: 10, minViews: 1 } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -171,7 +171,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter segments by min votes", (done) => {
client.get(endpoint, { params: { videoID: "searchTest2", minVotes: 0 }})
client.get(endpoint, { params: { videoID: "searchTest2", minVotes: 0 } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -186,7 +186,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter segments by max votes", (done) => {
client.get(endpoint, { params: { videoID: "searchTest2", maxVotes: 10 }})
client.get(endpoint, { params: { videoID: "searchTest2", maxVotes: 10 } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -201,7 +201,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to filter segments by both min and max votes", (done) => {
client.get(endpoint, { params: { videoID: "searchTest2", maxVotes: 10, minVotes: 0 }})
client.get(endpoint, { params: { videoID: "searchTest2", maxVotes: 10, minVotes: 0 } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -215,7 +215,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to get first page of results", (done) => {
client.get(endpoint, { params: { videoID: "searchTest4" }})
client.get(endpoint, { params: { videoID: "searchTest4" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -238,7 +238,7 @@ describe("getSearchSegments", () => {
});
it("Should be able to get second page of results", (done) => {
client.get(endpoint, { params: { videoID: "searchTest4", page: 1 }})
client.get(endpoint, { params: { videoID: "searchTest4", page: 1 } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;

View File

@@ -1,4 +1,4 @@
import {db} from "../../src/databases/databases";
import { db } from "../../src/databases/databases";
import { partialDeepEquals } from "../utils/partialDeepEquals";
import assert from "assert";
import { client } from "../utils/httpClient";
@@ -169,7 +169,7 @@ describe("getSegmentInfo", () => {
});
it("Should be able to retreive single segment in array", (done) => {
client.get(endpoint, { params: { UUIDs: `["${upvotedID}"]` }})
client.get(endpoint, { params: { UUIDs: `["${upvotedID}"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -185,7 +185,7 @@ describe("getSegmentInfo", () => {
});
it("Should be able to retreive multiple segments in array", (done) => {
client.get(endpoint, { params: { UUIDs: `["${upvotedID}", "${downvotedID}"]` }})
client.get(endpoint, { params: { UUIDs: `["${upvotedID}", "${downvotedID}"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -204,7 +204,7 @@ describe("getSegmentInfo", () => {
});
it("Should be possible to send unexpected query parameters", (done) => {
client.get(endpoint, { params: { UUID: upvotedID, fakeparam: "hello", category: "sponsor" }})
client.get(endpoint, { params: { UUID: upvotedID, fakeparam: "hello", category: "sponsor" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -273,7 +273,7 @@ describe("getSegmentInfo", () => {
it("Should cut off array at 10", function(done) {
this.timeout(10000);
const filledIDArray = `["${upvotedID}", "${downvotedID}", "${lockedupID}", "${shadowhiddenID}", "${lockeddownID}", "${hiddenID}", "${fillerID1}", "${fillerID2}", "${fillerID3}", "${fillerID4}", "${fillerID5}"]`;
client.get(endpoint, { params: { UUIDs: filledIDArray }})
client.get(endpoint, { params: { UUIDs: filledIDArray } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -298,7 +298,7 @@ describe("getSegmentInfo", () => {
});
it("Should return 400 if UUID not found", (done) => {
client.get(endpoint, { params: { UUID: ENOENTID }})
client.get(endpoint, { params: { UUID: ENOENTID } })
.then(res => {
if (res.status !== 400) done(`non 400 response code: ${res.status}`);
else done(); // pass

View File

@@ -1,4 +1,4 @@
import {db} from "../../src/databases/databases";
import { db } from "../../src/databases/databases";
import { partialDeepEquals } from "../utils/partialDeepEquals";
import assert from "assert";
import { client } from "../utils/httpClient";
@@ -27,7 +27,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get a time by category 1", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "sponsor" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "sponsor" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -43,7 +43,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get a time by category and action type", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "sponsor", actionType: "mute" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "sponsor", actionType: "mute" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -81,7 +81,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get a time by category and getSkipSegmentMultiple action types (JSON array)", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "sponsor", actionTypes: `["mute","skip"]` }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "sponsor", actionTypes: `["mute","skip"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -100,7 +100,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get a time by category for a different service 1", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID1", category: "sponsor", service: "PeerTube" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID1", category: "sponsor", service: "PeerTube" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -118,7 +118,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get a time by category 2", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "intro" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", category: "intro" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -135,7 +135,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get a time by categories array", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `["sponsor"]` }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `["sponsor"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -153,7 +153,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get a time by categories array 2", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `["intro"]` }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `["intro"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -171,7 +171,7 @@ describe("getSkipSegments", () => {
});
it("Should return 404 if all submissions are hidden", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID6" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID6" } })
.then(res => {
assert.strictEqual(res.status, 404);
done();
@@ -180,7 +180,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get getSkipSegmentMultiple times by category", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentMultiple", categories: `["intro"]` }})
client.get(endpoint, { params: { videoID: "getSkipSegmentMultiple", categories: `["intro"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -201,7 +201,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get getSkipSegmentMultiple times by getSkipSegmentMultiple categories", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `["sponsor", "intro"]` }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `["sponsor", "intro"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -222,7 +222,7 @@ describe("getSkipSegments", () => {
});
it("Should be possible to send unexpected query parameters", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", fakeparam: "hello", category: "sponsor" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", fakeparam: "hello", category: "sponsor" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -239,7 +239,7 @@ describe("getSkipSegments", () => {
});
it("Low voted submissions should be hidden", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID3", category: "sponsor" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID3", category: "sponsor" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -256,7 +256,7 @@ describe("getSkipSegments", () => {
});
it("Should return 404 if no segment found", (done) => {
client.get(endpoint, { params: { videoID: "notarealvideo" }})
client.get(endpoint, { params: { videoID: "notarealvideo" } })
.then(res => {
assert.strictEqual(res.status, 404);
done();
@@ -265,7 +265,7 @@ describe("getSkipSegments", () => {
});
it("Should return 400 if bad categories argument", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `[not-quoted,not-quoted]` }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID0", categories: `[not-quoted,not-quoted]` } })
.then(res => {
assert.strictEqual(res.status, 400);
done();
@@ -274,7 +274,7 @@ describe("getSkipSegments", () => {
});
it("Should be able send a comma in a query param", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentID2", category: "sponsor" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentID2", category: "sponsor" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -291,7 +291,7 @@ describe("getSkipSegments", () => {
});
it("Should always get getSkipSegmentLocked segment", (done) => {
client.get(endpoint, { params: { videoID: "getSkipSegmentLocked", category: "intro" }})
client.get(endpoint, { params: { videoID: "getSkipSegmentLocked", category: "intro" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -308,7 +308,7 @@ describe("getSkipSegments", () => {
});
it("Should be able to get getSkipSegmentMultiple categories with repeating parameters", (done) => {
client.get(`${endpoint}?category=sponsor&category=intro`, { params: { videoID: "getSkipSegmentID0" }})
client.get(`${endpoint}?category=sponsor&category=intro`, { params: { videoID: "getSkipSegmentID0" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -348,7 +348,7 @@ describe("getSkipSegments", () => {
it("Should be able to get specific segments with requiredSegments", (done) => {
const required2 = "requiredSegmentVid2";
const required3 = "requiredSegmentVid3";
client.get(endpoint, { params: { videoID: "requiredSegmentVid", requiredSegments: `["${required2}","${required3}"]` }})
client.get(endpoint, { params: { videoID: "requiredSegmentVid", requiredSegments: `["${required2}","${required3}"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;

View File

@@ -1,9 +1,9 @@
import {db} from "../../src/databases/databases";
import { db } from "../../src/databases/databases";
import { partialDeepEquals } from "../utils/partialDeepEquals";
import {getHash} from "../../src/utils/getHash";
import {ImportMock,} from "ts-mock-imports";
import { getHash } from "../../src/utils/getHash";
import { ImportMock, } from "ts-mock-imports";
import * as YouTubeAPIModule from "../../src/utils/youtubeApi";
import {YouTubeApiMock} from "../youtubeMock";
import { YouTubeApiMock } from "../youtubeMock";
import assert from "assert";
import { client } from "../utils/httpClient";
@@ -33,7 +33,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should be able to get a 200", (done) => {
client.get(`${endpoint}/3272f`, { params: { categories: `["sponsor", "intro"]` }})
client.get(`${endpoint}/3272f`, { params: { categories: `["sponsor", "intro"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
done();
@@ -42,7 +42,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should return 404 if no segments are found even if a video for the given hash is known", (done) => {
client.get(`${endpoint}/3272f`, { params: { categories: `["shilling"]` }})
client.get(`${endpoint}/3272f`, { params: { categories: `["shilling"]` } })
.then(res => {
assert.strictEqual(res.status, 404);
assert.equal(res.data.length, 0);
@@ -52,7 +52,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should be able to get an empty array if no videos", (done) => {
client.get(`${endpoint}/11111`, { params: { categories: `["shilling"]` }})
client.get(`${endpoint}/11111`, { params: { categories: `["shilling"]` } })
.then(res => {
assert.strictEqual(res.status, 404);
const body = res.data;
@@ -63,7 +63,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should be able to get an empty array if only hidden videos", (done) => {
client.get(`${endpoint}/f3a1`, { params: { categories:`["sponsor"]` }})
client.get(`${endpoint}/f3a1`, { params: { categories:`["sponsor"]` } })
.then(res => {
if (res.status !== 404) done(`non 404 status code, was ${res.status}`);
else {
@@ -76,7 +76,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should return 400 prefix too short", (done) => {
client.get(`${endpoint}/11`, { params: { categories: `["shilling"]` }})
client.get(`${endpoint}/11`, { params: { categories: `["shilling"]` } })
.then(res => {
assert.strictEqual(res.status, 400);
done();
@@ -87,7 +87,7 @@ describe("getSkipSegmentsByHash", () => {
it("Should return 400 prefix too long", (done) => {
const prefix = "1".repeat(50);
assert.ok(prefix.length > 33, "failed to generate long enough string");
client.get(`${endpoint}/${prefix}`, { params: { categories: `["shilling"]` }})
client.get(`${endpoint}/${prefix}`, { params: { categories: `["shilling"]` } })
.then(res => {
assert.strictEqual(res.status, 400);
done();
@@ -97,7 +97,7 @@ describe("getSkipSegmentsByHash", () => {
it("Should return 404 prefix in range", (done) => {
const prefix = "1".repeat(5);
client.get(`${endpoint}/${prefix}`, { params: { categories: `["shilling"]` }})
client.get(`${endpoint}/${prefix}`, { params: { categories: `["shilling"]` } })
.then(res => {
assert.strictEqual(res.status, 404);
done();
@@ -106,7 +106,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should return 400 for no hash", (done) => {
client.get(`${endpoint}`, { params: { categories: `["shilling"]` }})
client.get(`${endpoint}`, { params: { categories: `["shilling"]` } })
.then(res => {
assert.strictEqual(res.status, 400);
done();
@@ -115,7 +115,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should return 400 for bad format categories", (done) => {
client.get(`${endpoint}/fdaf`, { params: { categories: "shilling" }})
client.get(`${endpoint}/fdaf`, { params: { categories: "shilling" } })
.then(res => {
assert.strictEqual(res.status, 400);
done();
@@ -124,7 +124,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should be able to get multiple videos", (done) => {
client.get(`${endpoint}/fdaf`, { params: { categories: `["sponsor","intro"]` }})
client.get(`${endpoint}/fdaf`, { params: { categories: `["sponsor","intro"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -161,7 +161,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should be able to get 200 for no categories (default sponsor) with action type", (done) => {
client.get(`${endpoint}/fdaf`, { params: { actionType: "skip" }})
client.get(`${endpoint}/fdaf`, { params: { actionType: "skip" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -235,7 +235,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should be able to get 200 for no categories (default sponsor) for a non YouTube service", (done) => {
client.get(`${endpoint}/fdaf`, { params: { service: "PeerTube" }})
client.get(`${endpoint}/fdaf`, { params: { service: "PeerTube" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -253,7 +253,7 @@ describe("getSkipSegmentsByHash", () => {
});
it("Should only return one segment when fetching highlight segments", (done) => {
client.get(`${endpoint}/c962`, { params: { category: "poi_highlight" }})
client.get(`${endpoint}/c962`, { params: { category: "poi_highlight" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;

View File

@@ -1,5 +1,5 @@
import assert from "assert";
import {db} from "../../src/databases/databases";
import { db } from "../../src/databases/databases";
import { client } from "../utils/httpClient";
let dbVersion: number;

View File

@@ -1,4 +1,4 @@
import {getSubmissionUUID} from "../../src/utils/getSubmissionUUID";
import { getSubmissionUUID } from "../../src/utils/getSubmissionUUID";
import assert from "assert";
import { ActionType, VideoID } from "../../src/types/segments.model";
import { UserID } from "../../src/types/user.model";

View File

@@ -1,11 +1,11 @@
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import assert from "assert";
import { client } from "../utils/httpClient";
import { AxiosResponse } from "axios";
const endpoint = "/api/userID";
const getUserName = (username: string): Promise<AxiosResponse> => client.get(endpoint, { params: { username }});
const getUserName = (username: string): Promise<AxiosResponse> => client.get(endpoint, { params: { username } });
describe("getUserID", () => {
before(async () => {
@@ -43,7 +43,7 @@ describe("getUserID", () => {
});
it("Should be able to get a 200 (username is public id)", (done) => {
client.get(endpoint, { params: { username: getHash("getuserid_user_06") }})
client.get(endpoint, { params: { username: getHash("getuserid_user_06") } })
.then(res => {
assert.strictEqual(res.status, 200);
done();
@@ -52,7 +52,7 @@ describe("getUserID", () => {
});
it("Should be able to get a 400 (username longer than 64 chars)", (done) => {
client.get(endpoint, { params: { username: `${getHash("getuserid_user_06")}0` }})
client.get(endpoint, { params: { username: `${getHash("getuserid_user_06")}0` } })
.then(res => {
assert.strictEqual(res.status, 400);
done();
@@ -61,7 +61,7 @@ describe("getUserID", () => {
});
it("Should be able to get single username", (done) => {
client.get(endpoint, { params: { username: "fuzzy user 01" }})
client.get(endpoint, { params: { username: "fuzzy user 01" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = [{
@@ -254,7 +254,7 @@ describe("getUserID", () => {
});
it("should allow exact match", (done) => {
client.get(endpoint, { params: { username: "a", exact: true }})
client.get(endpoint, { params: { username: "a", exact: true } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = [{
@@ -268,7 +268,7 @@ describe("getUserID", () => {
});
it("Should be able to get repeating username with exact username", (done) => {
client.get(endpoint, { params: { username: "repeating", exact: true }})
client.get(endpoint, { params: { username: "repeating", exact: true } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = [{
@@ -285,7 +285,7 @@ describe("getUserID", () => {
});
it("Should not get exact unless explicitly set to true", (done) => {
client.get(endpoint, { params: { username: "user", exact: 1 }})
client.get(endpoint, { params: { username: "user", exact: 1 } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = [{

View File

@@ -1,6 +1,6 @@
import { partialDeepEquals } from "../utils/partialDeepEquals";
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import assert from "assert";
import { client } from "../utils/httpClient";
@@ -35,7 +35,7 @@ describe("getUserInfo", () => {
});
it("Should be able to get a 200", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_user_01" }})
client.get(endpoint, { params: { userID: "getuserinfo_user_01" } })
.then(res => {
assert.strictEqual(res.status, 200);
done();
@@ -44,7 +44,7 @@ describe("getUserInfo", () => {
});
it("Should be able to get a 400 (No userID parameter)", (done) => {
client.get(endpoint, { params: { userID: "" }})
client.get(endpoint, { params: { userID: "" } })
.then(res => {
assert.strictEqual(res.status, 400);
done();
@@ -53,7 +53,7 @@ describe("getUserInfo", () => {
});
it("Should be able to get user info", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_user_01" }})
client.get(endpoint, { params: { userID: "getuserinfo_user_01" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -77,7 +77,7 @@ describe("getUserInfo", () => {
});
it("Should get warning data", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_warning_0", value: "warnings" }})
client.get(endpoint, { params: { userID: "getuserinfo_warning_0", value: "warnings" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -90,7 +90,7 @@ describe("getUserInfo", () => {
});
it("Should get warning data with public ID", (done) => {
client.get(endpoint, { params: { publicUserID: getHash("getuserinfo_warning_0"), values: `["warnings"]` }})
client.get(endpoint, { params: { publicUserID: getHash("getuserinfo_warning_0"), values: `["warnings"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -103,7 +103,7 @@ describe("getUserInfo", () => {
});
it("Should get multiple warnings", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_warning_1", value: "warnings" }})
client.get(endpoint, { params: { userID: "getuserinfo_warning_1", value: "warnings" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -116,7 +116,7 @@ describe("getUserInfo", () => {
});
it("Should not get warnings if none", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_warning_2", value: "warnings" }})
client.get(endpoint, { params: { userID: "getuserinfo_warning_2", value: "warnings" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -129,7 +129,7 @@ describe("getUserInfo", () => {
});
it("Should done(userID for userName (No userName set)", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_user_02", value: "userName" }})
client.get(endpoint, { params: { userID: "getuserinfo_user_02", value: "userName" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -142,7 +142,7 @@ describe("getUserInfo", () => {
});
it("Should return null segment if none", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_null", value: "lastSegmentID" }})
client.get(endpoint, { params: { userID: "getuserinfo_null", value: "lastSegmentID" } })
.then(res => {
assert.strictEqual(res.status, 200);
assert.strictEqual(res.data.lastSegmentID, null);
@@ -152,7 +152,7 @@ describe("getUserInfo", () => {
});
it("Should return zeroes if userid does not exist", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_null", value: "lastSegmentID" }})
client.get(endpoint, { params: { userID: "getuserinfo_null", value: "lastSegmentID" } })
.then(res => {
const data = res.data;
for (const value in data) {
@@ -166,7 +166,7 @@ describe("getUserInfo", () => {
});
it("Should get warning reason from from single enabled warning", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_warning_0", values: `["warningReason"]` }})
client.get(endpoint, { params: { userID: "getuserinfo_warning_0", values: `["warningReason"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -179,7 +179,7 @@ describe("getUserInfo", () => {
});
it("Should get most recent warning from two enabled warnings", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_warning_1", value: "warningReason" }})
client.get(endpoint, { params: { userID: "getuserinfo_warning_1", value: "warningReason" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -192,7 +192,7 @@ describe("getUserInfo", () => {
});
it("Should not get disabled warning", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_warning_2", values: `["warnings","warningReason"]` }})
client.get(endpoint, { params: { userID: "getuserinfo_warning_2", values: `["warnings","warningReason"]` } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -220,7 +220,7 @@ describe("getUserInfo", () => {
});
it("Should get 400 if bad values specified", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_warning_3", value: "invalid-value" }})
client.get(endpoint, { params: { userID: "getuserinfo_warning_3", value: "invalid-value" } })
.then(res => {
assert.strictEqual(res.status, 400);
done(); // pass
@@ -229,7 +229,7 @@ describe("getUserInfo", () => {
});
it("Should get ban data for banned user (only appears when specifically requested)", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_ban_01", value: "banned" }})
client.get(endpoint, { params: { userID: "getuserinfo_ban_01", value: "banned" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -242,7 +242,7 @@ describe("getUserInfo", () => {
});
it("Should get ban data for unbanned user (only appears when specifically requested)", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_notban_01", value: "banned" }})
client.get(endpoint, { params: { userID: "getuserinfo_notban_01", value: "banned" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -255,7 +255,7 @@ describe("getUserInfo", () => {
});
it("Should throw 400 on bad json in values", (done) => {
client.get(endpoint, { params: { userID: "x", values: `[userID]` }})
client.get(endpoint, { params: { userID: "x", values: `[userID]` } })
.then(res => {
assert.strictEqual(res.status, 400);
done(); // pass
@@ -264,7 +264,7 @@ describe("getUserInfo", () => {
});
it("Should return 200 on userID not found", (done) => {
client.get(endpoint, { params: { userID: "notused-userid" }})
client.get(endpoint, { params: { userID: "notused-userid" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -285,7 +285,7 @@ describe("getUserInfo", () => {
});
it("Should only count long segments as 10 minutes", (done) => {
client.get(endpoint, { params: { userID: "getuserinfo_user_03" }})
client.get(endpoint, { params: { userID: "getuserinfo_user_03" } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {

View File

@@ -33,7 +33,7 @@ describe("getUserStats", () => {
});
it("Should be able to get all user info", (done) => {
client.get(endpoint, { params: { userID: "getuserstats_user_01", fetchCategoryStats: true, fetchActionTypeStats: true }})
client.get(endpoint, { params: { userID: "getuserstats_user_01", fetchCategoryStats: true, fetchActionTypeStats: true } })
.then(res => {
assert.strictEqual(res.status, 200);
const expected = {
@@ -65,7 +65,7 @@ describe("getUserStats", () => {
});
it("Should be able to get all zeroes for invalid userid", (done) => {
client.get(endpoint, { params: { userID: "getuserstats_user_invalid" }})
client.get(endpoint, { params: { userID: "getuserstats_user_invalid" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -80,7 +80,7 @@ describe("getUserStats", () => {
});
it("Should be able to get all zeroes for only ignored segments", (done) => {
client.get(endpoint, { params: { userID: "getuserstats_user_02" }})
client.get(endpoint, { params: { userID: "getuserstats_user_02" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -95,7 +95,7 @@ describe("getUserStats", () => {
});
it("Should not get extra stats if not requested", (done) => {
client.get(endpoint, { params: { userID: "getuserstats_user_01" }})
client.get(endpoint, { params: { userID: "getuserstats_user_01" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;
@@ -109,7 +109,7 @@ describe("getUserStats", () => {
});
it("Should get parts of extra stats if not requested", (done) => {
client.get(endpoint, { params: { userID: "getuserstats_user_01", fetchActionTypeStats: true }})
client.get(endpoint, { params: { userID: "getuserstats_user_01", fetchActionTypeStats: true } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;

View File

@@ -1,7 +1,7 @@
import {getHash} from "../../src/utils/getHash";
import {db} from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import assert from "assert";
import {LockCategory } from "../../src/types/segments.model";
import { LockCategory } from "../../src/types/segments.model";
import { client } from "../utils/httpClient";
const stringDeepEquals = (a: string[] ,b: string[]): boolean => {
@@ -455,7 +455,7 @@ describe("lockCategoriesRecords", () => {
"shilling"
],
};
client.get(endpoint, { params: {videoID: "no-segments-video-id" }})
client.get(endpoint, { params: { videoID: "no-segments-video-id" } })
.then(res => {
assert.strictEqual(res.status, 200);
const data = res.data;

View File

@@ -1,4 +1,4 @@
import {db} from "../../src/databases/databases";
import { db } from "../../src/databases/databases";
import { partialDeepEquals } from "../utils/partialDeepEquals";
import assert from "assert";
import { client } from "../utils/httpClient";
@@ -33,7 +33,7 @@ describe("getVideoSponsorTime (Old get method)", () => {
it("Should be possible to send unexpected query parameters", (done) => {
client.get(endpoint, { params: { videoID: "oldGetSponsorTime0", fakeparam: "hello" }})
client.get(endpoint, { params: { videoID: "oldGetSponsorTime0", fakeparam: "hello" } })
.then(res => {
assert.strictEqual(res.status, 200);
done();

View File

@@ -1,4 +1,4 @@
import { partialDeepEquals } from "../utils/partialDeepEquals";import {db} from "../../src/databases/databases";
import { partialDeepEquals } from "../utils/partialDeepEquals";import { db } from "../../src/databases/databases";
import assert from "assert";
import { client } from "../utils/httpClient";
@@ -9,7 +9,7 @@ const endpoint = "/api/postVideoSponsorTimes";
describe("postVideoSponsorTime (Old submission method)", () => {
it("Should be able to submit a time (GET)", (done) => {
client.get(endpoint, { params: { videoID: videoID1, startTime: 1, endTime: 10, userID }})
client.get(endpoint, { params: { videoID: videoID1, startTime: 1, endTime: 10, userID } })
.then(async res => {
assert.strictEqual(res.status, 200);
const row = await db.prepare("get", `SELECT "startTime", "endTime", "category" FROM "sponsorTimes" WHERE "videoID" = ?`, [videoID1]);
@@ -45,7 +45,7 @@ describe("postVideoSponsorTime (Old submission method)", () => {
});
it("Should return 400 for missing params", (done) => {
client.post(endpoint, { params: { startTime: 1, endTime: 10, userID }})
client.post(endpoint, { params: { startTime: 1, endTime: 10, userID } })
.then(res => {
assert.strictEqual(res.status, 400);
done();

View File

@@ -1,8 +1,8 @@
import fetch from "node-fetch";
import { Done } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import assert from "assert";
const VIPUser = "clearCacheVIP";

View File

@@ -1,9 +1,9 @@
import fetch from "node-fetch";
import {Done, postJSON} from "../utils/utils";
import { Done, postJSON } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import {IDatabase} from "../../src/databases/IDatabase";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { IDatabase } from "../../src/databases/IDatabase";
import assert from "assert";
async function dbSponsorTimesAdd(db: IDatabase, videoID: string, startTime: number, endTime: number, UUID: string, category: string) {

View File

@@ -1,13 +1,13 @@
import fetch from "node-fetch";
import {config} from "../../src/config";
import {getHash} from "../../src/utils/getHash";
import { config } from "../../src/config";
import { getHash } from "../../src/utils/getHash";
import { Done, postJSON } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import { partialDeepEquals } from "../utils/partialDeepEquals";
import {db} from "../../src/databases/databases";
import {ImportMock} from "ts-mock-imports";
import { db } from "../../src/databases/databases";
import { ImportMock } from "ts-mock-imports";
import * as YouTubeAPIModule from "../../src/utils/youtubeApi";
import {YouTubeApiMock} from "../youtubeMock";
import { YouTubeApiMock } from "../youtubeMock";
import assert from "assert";
const mockManager = ImportMock.mockStaticClass(YouTubeAPIModule, "YouTubeAPI");

View File

@@ -2,8 +2,8 @@ import fetch from "node-fetch";
import { Done, postJSON } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import { partialDeepEquals } from "../utils/partialDeepEquals";
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import assert from "assert";
describe("postWarning", () => {

View File

@@ -1,9 +1,9 @@
import fetch from "node-fetch";
import {Done, postJSON} from "../utils/utils";
import { Done, postJSON } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import {db} from "../../src/databases/databases";
import {getHash} from "../../src/utils/getHash";
import {IDatabase} from "../../src/databases/IDatabase";
import { db } from "../../src/databases/databases";
import { getHash } from "../../src/utils/getHash";
import { IDatabase } from "../../src/databases/IDatabase";
import assert from "assert";
describe("segmentShift", function () {

View File

@@ -1,8 +1,8 @@
import fetch from "node-fetch";
import {db} from "../../src/databases/databases";
import { db } from "../../src/databases/databases";
import { Done } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import {getHash} from "../../src/utils/getHash";
import { getHash } from "../../src/utils/getHash";
import assert from "assert";
import { Category } from "../../src/types/segments.model";

View File

@@ -15,8 +15,8 @@ describe("Test utils ", () => {
false
), "Did not match empty expect");
assert(partialDeepEquals(
[{a: [1,2,3]}, {a: [1,2]}],
[{a: [1,2,3]}, {a: [1,2]}]
[{ a: [1,2,3] }, { a: [1,2] }],
[{ a: [1,2,3] }, { a: [1,2] }]
), "Did not match same arrays");
assert(partialDeepEquals(
{

View File

@@ -1,12 +1,12 @@
import fetch from "node-fetch";
import {config} from "../../src/config";
import {db} from "../../src/databases/databases";
import { config } from "../../src/config";
import { db } from "../../src/databases/databases";
import { Done } from "../utils/utils";
import { getbaseURL } from "../utils/getBaseURL";
import {getHash} from "../../src/utils/getHash";
import {ImportMock} from "ts-mock-imports";
import { getHash } from "../../src/utils/getHash";
import { ImportMock } from "ts-mock-imports";
import * as YouTubeAPIModule from "../../src/utils/youtubeApi";
import {YouTubeApiMock} from "../youtubeMock";
import { YouTubeApiMock } from "../youtubeMock";
import assert from "assert";
const mockManager = ImportMock.mockStaticClass(YouTubeAPIModule, "YouTubeAPI");

View File

@@ -1,5 +1,5 @@
import express from "express";
import {config} from "../src/config";
import { config } from "../src/config";
import { Server } from "http";
const app = express();

View File

@@ -1,12 +1,12 @@
import Mocha from "mocha";
import fs from "fs";
import path from "path";
import {config} from "../src/config";
import {createServer} from "../src/app";
import {createMockServer} from "./mocks";
import {Logger} from "../src/utils/logger";
import {initDb} from "../src/databases/databases";
import {ImportMock} from "ts-mock-imports";
import { config } from "../src/config";
import { createServer } from "../src/app";
import { createMockServer } from "./mocks";
import { Logger } from "../src/utils/logger";
import { initDb } from "../src/databases/databases";
import { ImportMock } from "ts-mock-imports";
import * as rateLimitMiddlewareModule from "../src/middleware/requestRateLimit";
import rateLimit from "express-rate-limit";