diff --git a/test/service/balance.js b/test/service/balance.js index 41d89329..8a38c2aa 100644 --- a/test/service/balance.js +++ b/test/service/balance.js @@ -23,6 +23,7 @@ describe("service/balance", () => { expect(result).to.equal(Infinity); }); + it("should allow for configurable maximum", async () => { sinon.stub(config, "maximum").value(10); sinon.stub(recognitionCollection, "count").resolves(1); @@ -35,6 +36,7 @@ describe("service/balance", () => { expect(result).to.equal(9); }); }); + describe("currentBalance", () => { it("should return total earnings when users have no deductions", async () => { sinon.stub(recognitionCollection, "count").resolves(100); @@ -56,6 +58,7 @@ describe("service/balance", () => { expect(result).to.equal(180); }); }); + describe("lifetimeSpendings", () => { it("should sum the total deduction value returned from the db", async () => { sinon.stub(deductionCollection, "find").resolves([ diff --git a/test/service/deduction.js b/test/service/deduction.js index 8dfe1eb9..9557df69 100644 --- a/test/service/deduction.js +++ b/test/service/deduction.js @@ -28,6 +28,7 @@ describe("deduction/balance", () => { }; expect(insert.args[0][0]).to.deep.equal(object); }); + it("should allow for message to be optional", async () => { const insert = sinon.stub(deductionCollection, "insert").resolves({}); sinon.useFakeTimers(new Date(2020, 1, 1)); @@ -44,6 +45,7 @@ describe("deduction/balance", () => { expect(insert.args[0][0]).to.deep.equal(object); }); }); + describe("refundDeduction", () => { it("should call refund deduction", async () => { const findOneAndUpdate = sinon @@ -56,6 +58,7 @@ describe("deduction/balance", () => { }); }); }); + describe("isBalanceSufficent", () => { it("should return true if balance is sufficient", async () => { sinon.stub(balance, "currentBalance").resolves(20); @@ -63,6 +66,7 @@ describe("deduction/balance", () => { const result = await deduction.isBalanceSufficent("testUser", 10); expect(result).to.be.true; }); + it("should return false if balance is not sufficient", async () => { sinon.stub(balance, "currentBalance").resolves(20); @@ -70,6 +74,7 @@ describe("deduction/balance", () => { expect(result).to.be.false; }); }); + describe("getDeductions", () => { it("should return deductions found in db", async () => { sinon.stub(deductionCollection, "find").resolves([ @@ -89,6 +94,7 @@ describe("deduction/balance", () => { ]; expect(result).to.deep.equal(object); }); + it("should filter results if times are specified", async () => { const find = sinon.stub(deductionCollection, "find").resolves([]); sinon.useFakeTimers(new Date(Date.UTC(2020, 1, 1))); diff --git a/test/service/leaderboard.js b/test/service/leaderboard.js index b4e5284f..1e001587 100644 --- a/test/service/leaderboard.js +++ b/test/service/leaderboard.js @@ -12,6 +12,7 @@ describe("service/leaderboard", () => { timestamp: "2022-02-01", }); }); + afterEach(() => { sinon.restore(); }); diff --git a/test/service/messageutils.js b/test/service/messageutils.js index ed279042..3ec2a083 100644 --- a/test/service/messageutils.js +++ b/test/service/messageutils.js @@ -10,7 +10,7 @@ describe("service/messageutils", () => { sinon.restore(); }); - describe("handleSlackError", async () => { + describe("handleSlackError", () => { it("should return the proper message", async () => { const testClient = { chat: { @@ -34,7 +34,7 @@ describe("service/messageutils", () => { }); }); - describe("handleGratitudeError", async () => { + describe("handleGratitudeError", () => { it("should return the proper message", async () => { const testClient = { chat: { @@ -62,7 +62,7 @@ describe("service/messageutils", () => { }); }); - describe("handleGenericError", async () => { + describe("handleGenericError", () => { it("should return the proper message", async () => { const testClient = { chat: { @@ -137,6 +137,7 @@ describe("service/messageutils", () => { `You earned a ${goldenRecognizeEmoji}!!!`, ); }); + it("should get fistbump message", () => { const testGratitude = { type: recognizeEmoji, diff --git a/test/service/recognition.js b/test/service/recognition.js index 593b2dc6..6e4ca80b 100644 --- a/test/service/recognition.js +++ b/test/service/recognition.js @@ -222,6 +222,7 @@ describe("service/recognition", () => { expect(insert.args[0][0]).to.deep.equal(object); }); }); + describe("countRecognitionsReceived", () => { it("should return count of recognition in db", async () => { sinon.stub(recognitionCollection, "count").resolves(10); @@ -230,6 +231,7 @@ describe("service/recognition", () => { expect(result).to.equal(10); }); + it("should filter results if times are specified", async () => { const count = sinon.stub(recognitionCollection, "count").resolves(0); sinon.useFakeTimers(new Date(Date.UTC(2020, 1, 1))); @@ -250,6 +252,7 @@ describe("service/recognition", () => { expect(count.args[0][0]).to.deep.equal(filter); }); }); + describe("countRecognitionsGiven", () => { it("should return count of recognition in db", async () => { sinon.stub(recognitionCollection, "count").resolves(10); @@ -258,6 +261,7 @@ describe("service/recognition", () => { expect(result).to.equal(10); }); + it("should filter results if times are specified", async () => { const count = sinon.stub(recognitionCollection, "count").resolves(0); sinon.useFakeTimers(new Date(Date.UTC(2020, 1, 1))); @@ -278,6 +282,7 @@ describe("service/recognition", () => { expect(count.args[0][0]).to.deep.equal(filter); }); }); + describe("getPreviousXDaysOfRecognition", () => { it("should return recognition in db", async () => { sinon.stub(recognitionCollection, "find").resolves([ @@ -305,6 +310,7 @@ describe("service/recognition", () => { ]; expect(result).to.deep.equal(object); }); + it("should filter results if times are specified", async () => { const find = sinon.stub(recognitionCollection, "find").resolves([]); sinon.useFakeTimers(new Date(Date.UTC(2020, 1, 1))); @@ -1264,6 +1270,7 @@ describe("service/recognition", () => { expect(recognition.validateAndSendGratitude(gratitude)).to.be.rejected; }); }); + describe("giverSlackNotification", () => { it("should generate a markdown response for recognition", async () => { sinon.stub(balance, "dailyGratitudeRemaining").resolves(5); @@ -1329,6 +1336,7 @@ describe("service/recognition", () => { expect(response).to.deep.equal(expectedResponse); }); }); + describe("giverGoldenSlackNotification", () => { it("default path for golden fistbump", async () => { const gratitude = { @@ -1362,6 +1370,7 @@ describe("service/recognition", () => { expect(response).to.deep.equal(expectedResponse); }); }); + describe("receiverSlackNotification", () => { it("should generate a markdown response for recognition", async () => { sinon.stub(balance, "lifetimeEarnings").resolves(100); diff --git a/test/service/refund.js b/test/service/refund.js index 1e4552bd..582bcfd7 100644 --- a/test/service/refund.js +++ b/test/service/refund.js @@ -33,9 +33,7 @@ describe("service/refund", () => { text: "Refund Successfully given", }); }); - }); - describe("respondToRefund", () => { it("should return a message informing user that they must be redemption admin", async () => { const testMessage = { user: "testUser",