Skip to content

Commit

Permalink
style: fix style errors in mocha tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pactionly committed Jun 11, 2024
1 parent 74e6344 commit 9392cd2
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 5 deletions.
3 changes: 3 additions & 0 deletions test/service/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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([
Expand Down
6 changes: 6 additions & 0 deletions test/service/deduction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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
Expand All @@ -56,20 +58,23 @@ describe("deduction/balance", () => {
});
});
});

describe("isBalanceSufficent", () => {
it("should return true if balance is sufficient", async () => {
sinon.stub(balance, "currentBalance").resolves(20);

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);

const result = await deduction.isBalanceSufficent("testUser", 30);
expect(result).to.be.false;
});
});

describe("getDeductions", () => {
it("should return deductions found in db", async () => {
sinon.stub(deductionCollection, "find").resolves([
Expand All @@ -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)));
Expand Down
1 change: 1 addition & 0 deletions test/service/leaderboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ describe("service/leaderboard", () => {
timestamp: "2022-02-01",
});
});

afterEach(() => {
sinon.restore();
});
Expand Down
7 changes: 4 additions & 3 deletions test/service/messageutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ describe("service/messageutils", () => {
sinon.restore();
});

describe("handleSlackError", async () => {
describe("handleSlackError", () => {
it("should return the proper message", async () => {
const testClient = {
chat: {
Expand All @@ -34,7 +34,7 @@ describe("service/messageutils", () => {
});
});

describe("handleGratitudeError", async () => {
describe("handleGratitudeError", () => {
it("should return the proper message", async () => {
const testClient = {
chat: {
Expand Down Expand Up @@ -62,7 +62,7 @@ describe("service/messageutils", () => {
});
});

describe("handleGenericError", async () => {
describe("handleGenericError", () => {
it("should return the proper message", async () => {
const testClient = {
chat: {
Expand Down Expand Up @@ -137,6 +137,7 @@ describe("service/messageutils", () => {
`You earned a ${goldenRecognizeEmoji}!!!`,
);
});

it("should get fistbump message", () => {
const testGratitude = {
type: recognizeEmoji,
Expand Down
9 changes: 9 additions & 0 deletions test/service/recognition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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)));
Expand All @@ -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);
Expand All @@ -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)));
Expand All @@ -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([
Expand Down Expand Up @@ -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)));
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1329,6 +1336,7 @@ describe("service/recognition", () => {
expect(response).to.deep.equal(expectedResponse);
});
});

describe("giverGoldenSlackNotification", () => {
it("default path for golden fistbump", async () => {
const gratitude = {
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions test/service/refund.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 9392cd2

Please sign in to comment.