fixed accidentally nested test

This commit is contained in:
Alex Holliday committed 2024-10-14 13:27:03 +08:00
1 parent fde9303b8f
commit 98136c5fb1
1 file changed
+35 -35
@@ -127,42 +127,42 @@ describe("Queue Controller - addJob", () => {
msg: successMessages.QUEUE_ADD_JOB, msg: successMessages.QUEUE_ADD_JOB,
}); });
}); });
});
describe("Queue Controller - obliterateQueue", () => { describe("Queue Controller - obliterateQueue", () => {
beforeEach(() => { beforeEach(() => {
req = { req = {
headers: {}, headers: {},
params: {}, params: {},
body: {}, body: {},
db: {}, db: {},
jobQueue: { jobQueue: {
obliterate: sinon.stub(), obliterate: sinon.stub(),
}, },
}; };
res = { res = {
status: sinon.stub().returnsThis(), status: sinon.stub().returnsThis(),
json: sinon.stub(), json: sinon.stub(),
}; };
next = sinon.stub(); next = sinon.stub();
handleError = sinon.stub(); handleError = sinon.stub();
}); });
afterEach(() => { afterEach(() => {
sinon.restore(); 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 () => {
req.jobQueue.obliterate.throws(new Error("obliterateQueue error")); req.jobQueue.obliterate.throws(new Error("obliterateQueue error"));
await obliterateQueue(req, res, next); await obliterateQueue(req, res, next);
expect(next.firstCall.args[0]).to.be.an("error"); expect(next.firstCall.args[0]).to.be.an("error");
expect(next.firstCall.args[0].message).to.equal("obliterateQueue 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 () => {
req.jobQueue.obliterate.resolves(); req.jobQueue.obliterate.resolves();
await obliterateQueue(req, res, next); await obliterateQueue(req, res, next);
expect(res.status.firstCall.args[0]).to.equal(200); expect(res.status.firstCall.args[0]).to.equal(200);
expect(res.json.firstCall.args[0]).to.deep.equal({ expect(res.json.firstCall.args[0]).to.deep.equal({
success: true, success: true,
msg: successMessages.QUEUE_OBLITERATE, msg: successMessages.QUEUE_OBLITERATE,
});
}); });
}); });
}); });