fix(test): Use 'npm run lint-fix' to fix 'mocha/no-mocha-arrows' like lint warnings

- ref: https://mochajs.org/#arrow-functions
This commit is contained in:
Mert Şişmanoğlu
2024-12-29 14:25:59 +03:00
parent 319e6d6017
commit fcda60fe5b
31 changed files with 1268 additions and 907 deletions
+16 -10
View File
@@ -6,18 +6,21 @@ import {
import StatusPage from "../../db/models/StatusPage.js";
import { errorMessages } from "../../utils/messages.js";
describe("statusPageModule", () => {
describe("statusPageModule", function() {
let statusPageFindOneStub, statusPageSaveStub, statusPageFindStub;
beforeEach(() => {
beforeEach(function() {
statusPageSaveStub = sinon.stub(StatusPage.prototype, "save");
statusPageFindOneStub = sinon.stub(StatusPage, "findOne");
statusPageFindStub = sinon.stub(StatusPage, "find");
});
afterEach(() => {
afterEach(function() {
sinon.restore();
});
describe("createStatusPage", () => {
it("should throw an error if a non-unique url is provided", async () => {
describe("createStatusPage", function() {
it("should throw an error if a non-unique url is provided", async function() {
statusPageFindOneStub.resolves(true);
try {
await createStatusPage({ url: "test" });
@@ -26,7 +29,8 @@ describe("statusPageModule", () => {
expect(error.message).to.equal(errorMessages.STATUS_PAGE_URL_NOT_UNIQUE);
}
});
it("should handle duplicate URL errors", async () => {
it("should handle duplicate URL errors", async function() {
const err = new Error("test");
err.code = 11000;
statusPageSaveStub.rejects(err);
@@ -36,7 +40,8 @@ describe("statusPageModule", () => {
expect(error).to.deep.equal(err);
}
});
it("should return a status page if a unique url is provided", async () => {
it("should return a status page if a unique url is provided", async function() {
statusPageFindOneStub.resolves(null);
statusPageFindStub.resolves([]);
const mockStatusPage = { url: "test" };
@@ -45,8 +50,9 @@ describe("statusPageModule", () => {
expect(statusPage.url).to.equal(mockStatusPage.url);
});
});
describe("getStatusPageByUrl", () => {
it("should throw an error if a status page is not found", async () => {
describe("getStatusPageByUrl", function() {
it("should throw an error if a status page is not found", async function() {
statusPageFindOneStub.resolves(null);
try {
await getStatusPageByUrl("test");
@@ -56,7 +62,7 @@ describe("statusPageModule", () => {
}
});
it("should return a status page if a status page is found", async () => {
it("should return a status page if a status page is found", async function() {
const mockStatusPage = { url: "test" };
statusPageFindOneStub.resolves(mockStatusPage);
const statusPage = await getStatusPageByUrl(mockStatusPage.url);