From 87727ef3606cee81ff3cff2416a2cda8c6575da2 Mon Sep 17 00:00:00 2001 From: Michael C Date: Thu, 22 Jul 2021 17:50:39 -0400 Subject: [PATCH] fix tests and linting --- test/cases/getSkipSegments.ts | 14 +++++++------- test/cases/getUserID.ts | 14 +++++++------- test/cases/postPurgeAllSegments.ts | 16 ++++++++-------- test/cases/postSkipSegments.ts | 5 ++++- test/cases/postWarning.ts | 19 +++++++++---------- 5 files changed, 35 insertions(+), 33 deletions(-) diff --git a/test/cases/getSkipSegments.ts b/test/cases/getSkipSegments.ts index 28d6a2b..6f710a6 100644 --- a/test/cases/getSkipSegments.ts +++ b/test/cases/getSkipSegments.ts @@ -341,12 +341,12 @@ describe("getSkipSegments", () => { .catch(err => done(err)); }); - it('Should get 400 if no videoID passed in', (done: Done) => { - fetch(getbaseURL() + '/api/skipSegments') - .then(async res => { - assert.strictEqual(res.status, 400); - done(); - }) - .catch(err => done(err)); + it("Should get 400 if no videoID passed in", (done: Done) => { + fetch(`${getbaseURL()}/api/skipSegments`) + .then(async res => { + assert.strictEqual(res.status, 400); + done(); + }) + .catch(err => done(err)); }); }); diff --git a/test/cases/getUserID.ts b/test/cases/getUserID.ts index 6a4ad30..bf85cf0 100644 --- a/test/cases/getUserID.ts +++ b/test/cases/getUserID.ts @@ -314,12 +314,12 @@ describe("getUserID", () => { .catch(err => done(err)); }); - it('should return 400 if no username parameter specified', (done: Done) => { - fetch(getbaseURL() + '/api/userID') - .then(res => { - assert.strictEqual(res.status, 400); - done(); - }) - .catch(() => ("couldn't call endpoint")); + it("should return 400 if no username parameter specified", (done: Done) => { + fetch(`${getbaseURL()}/api/userID`) + .then(res => { + assert.strictEqual(res.status, 400); + done(); + }) + .catch(() => ("couldn't call endpoint")); }); }); diff --git a/test/cases/postPurgeAllSegments.ts b/test/cases/postPurgeAllSegments.ts index 65bccbb..5c93cd1 100644 --- a/test/cases/postPurgeAllSegments.ts +++ b/test/cases/postPurgeAllSegments.ts @@ -82,17 +82,17 @@ describe("postPurgeAllSegments", function () { .catch(err => done(err)); }); - it('Should return 400 if missing body', function (done: Done) { + it("Should return 400 if missing body", function (done: Done) { fetch(`${baseURL}${route}`, { - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", } }) - .then(async res => { - assert.strictEqual(res.status, 400); - done(); - }) - .catch(err => done(err)); + .then(async res => { + assert.strictEqual(res.status, 400); + done(); + }) + .catch(err => done(err)); }); }); diff --git a/test/cases/postSkipSegments.ts b/test/cases/postSkipSegments.ts index 0bcaea1..21b15f9 100644 --- a/test/cases/postSkipSegments.ts +++ b/test/cases/postSkipSegments.ts @@ -584,7 +584,10 @@ describe("postSkipSegments", () => { .then(async res => { assert.strictEqual(res.status, 403); const errorMessage = await res.text(); - assert.strictEqual(errorMessage, "Reason01"); + const reason = "Reason01"; + const userID = "09dee632bfbb1acc9fda3169cc14b46e459b45cee4f4449be305590e612b5eb7" + const expected = `Submission rejected due to a warning from a moderator. This means that we noticed you were making some common mistakes that are not malicious, and we just want to clarify the rules. Could you please send a message in Discord or Matrix so we can further help you? Your userID is ${userID}. Warning reason: ${reason}`; + assert.strictEqual(errorMessage, expected); done(); }) .catch(err => done(err)); diff --git a/test/cases/postWarning.ts b/test/cases/postWarning.ts index b3c15f6..7f4d38b 100644 --- a/test/cases/postWarning.ts +++ b/test/cases/postWarning.ts @@ -99,18 +99,17 @@ describe("postWarning", () => { .catch(err => done(err)); }); - it('Should return 400 if missing body', (done: Done) => { - fetch(getbaseURL() - + "/api/warnUser", { - method: 'POST', + it("Should return 400 if missing body", (done: Done) => { + fetch(`${getbaseURL()}/api/warnUser`, { + method: "POST", headers: { - 'Content-Type': 'application/json', + "Content-Type": "application/json", } }) - .then(async res => { - assert.strictEqual(res.status, 400); - done(); - }) - .catch(err => done(err)); + .then(async res => { + assert.strictEqual(res.status, 400); + done(); + }) + .catch(err => done(err)); }); });