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:
1 parent
319e6d6017
commit
fcda60fe5b
31 files changed
+1268
-907
No files matched your search
@@ -8,9 +8,10 @@ import {
|
||||
import { successMessages } from "../../utils/messages.js";
|
||||
import sinon from "sinon";
|
||||
|
||||
describe("Queue Controller - getMetrics", () => {
|
||||
describe("Queue Controller - getMetrics", function() {
|
||||
let req, res, next;
|
||||
beforeEach(() => {
|
||||
|
||||
beforeEach(function() {
|
||||
req = {
|
||||
headers: {},
|
||||
params: {},
|
||||
@@ -26,17 +27,19 @@ describe("Queue Controller - getMetrics", () => {
|
||||
};
|
||||
next = sinon.stub();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sinon.restore();
|
||||
});
|
||||
it("should throw an error if getMetrics throws an error", async () => {
|
||||
|
||||
it("should throw an error if getMetrics throws an error", async function() {
|
||||
req.jobQueue.getMetrics.throws(new Error("getMetrics error"));
|
||||
await getMetrics(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].message).to.equal("getMetrics error");
|
||||
});
|
||||
|
||||
it("should return a success message and data if getMetrics is successful", async () => {
|
||||
it("should return a success message and data if getMetrics is successful", async function() {
|
||||
const data = { data: "metrics" };
|
||||
req.jobQueue.getMetrics.returns(data);
|
||||
await getMetrics(req, res, next);
|
||||
@@ -49,9 +52,10 @@ describe("Queue Controller - getMetrics", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Queue Controller - getJobs", () => {
|
||||
describe("Queue Controller - getJobs", function() {
|
||||
let req, res, next;
|
||||
beforeEach(() => {
|
||||
|
||||
beforeEach(function() {
|
||||
req = {
|
||||
headers: {},
|
||||
params: {},
|
||||
@@ -67,16 +71,19 @@ describe("Queue Controller - getJobs", () => {
|
||||
};
|
||||
next = sinon.stub();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sinon.restore();
|
||||
});
|
||||
it("should reject with an error if getJobs throws an error", async () => {
|
||||
|
||||
it("should reject with an error if getJobs throws an error", async function() {
|
||||
req.jobQueue.getJobStats.throws(new Error("getJobs error"));
|
||||
await getJobs(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].message).to.equal("getJobs error");
|
||||
});
|
||||
it("should return a success message and data if getJobs is successful", async () => {
|
||||
|
||||
it("should return a success message and data if getJobs is successful", async function() {
|
||||
const data = { data: "jobs" };
|
||||
req.jobQueue.getJobStats.returns(data);
|
||||
await getJobs(req, res, next);
|
||||
@@ -89,9 +96,10 @@ describe("Queue Controller - getJobs", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Queue Controller - addJob", () => {
|
||||
describe("Queue Controller - addJob", function() {
|
||||
let req, res, next;
|
||||
beforeEach(() => {
|
||||
|
||||
beforeEach(function() {
|
||||
req = {
|
||||
headers: {},
|
||||
params: {},
|
||||
@@ -107,16 +115,19 @@ describe("Queue Controller - addJob", () => {
|
||||
};
|
||||
next = sinon.stub();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sinon.restore();
|
||||
});
|
||||
it("should reject with an error if addJob throws an error", async () => {
|
||||
|
||||
it("should reject with an error if addJob throws an error", async function() {
|
||||
req.jobQueue.addJob.throws(new Error("addJob error"));
|
||||
await addJob(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].message).to.equal("addJob error");
|
||||
});
|
||||
it("should return a success message if addJob is successful", async () => {
|
||||
|
||||
it("should return a success message if addJob is successful", async function() {
|
||||
req.jobQueue.addJob.resolves();
|
||||
await addJob(req, res, next);
|
||||
expect(res.status.firstCall.args[0]).to.equal(200);
|
||||
@@ -127,9 +138,10 @@ describe("Queue Controller - addJob", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("Queue Controller - obliterateQueue", () => {
|
||||
describe("Queue Controller - obliterateQueue", function() {
|
||||
let req, res, next;
|
||||
beforeEach(() => {
|
||||
|
||||
beforeEach(function() {
|
||||
req = {
|
||||
headers: {},
|
||||
params: {},
|
||||
@@ -145,16 +157,19 @@ describe("Queue Controller - obliterateQueue", () => {
|
||||
};
|
||||
next = sinon.stub();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
sinon.restore();
|
||||
});
|
||||
it("should reject with an error if obliterateQueue throws an error", async () => {
|
||||
|
||||
it("should reject with an error if obliterateQueue throws an error", async function() {
|
||||
req.jobQueue.obliterate.throws(new Error("obliterateQueue error"));
|
||||
await obliterateQueue(req, res, next);
|
||||
expect(next.firstCall.args[0]).to.be.an("error");
|
||||
expect(next.firstCall.args[0].message).to.equal("obliterateQueue error");
|
||||
});
|
||||
it("should return a success message if obliterateQueue is successful", async () => {
|
||||
|
||||
it("should return a success message if obliterateQueue is successful", async function() {
|
||||
req.jobQueue.obliterate.resolves();
|
||||
await obliterateQueue(req, res, next);
|
||||
expect(res.status.firstCall.args[0]).to.equal(200);
|
||||
|
||||
Reference in new issue
Block a user