Skip to content

Commit

Permalink
test: leaderboard and deduction test error fix
Browse files Browse the repository at this point in the history
  • Loading branch information
zjorge96 committed Nov 13, 2023
1 parent 12a204c commit 3041c1c
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 203 deletions.
4 changes: 2 additions & 2 deletions service/leaderboard.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const winston = require("../winston");
const recognition = require("./recognition");
const { goldenFistbumpHolder } = require("./golden-recognition");
const golden_recognition = require("./golden-recognition");

const rank = [
"1st",
Expand All @@ -27,7 +27,7 @@ async function createLeaderboardBlocks(timeRange) {
const { giverScores, receiverScores } = await leaderboardScoreData(timeRange);

blocks.push(leaderboardHeader());
blocks.push(await goldenFistbumpHolder());
blocks.push(await golden_recognition.goldenFistbumpHolder());
blocks.push(topGivers(giverScores));
blocks.push(topReceivers(receiverScores));
blocks.push(timeRangeInfo(timeRange));
Expand Down
54 changes: 26 additions & 28 deletions test/service/deduction.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,35 +106,33 @@ describe("service/deduction", () => {
});
});

// FIX: This is currently throwing the following error:
// Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning a Promise, ensure it resolves.

describe("respondToRefund", () => {
// it("should return a successful refund message to user", async () => {
// const testMessage = {
// user: "testAdmin",
// channel: "testchannel",
// text: "@gratibot refund 62171d78b5daaa0011771cfd",
// };
// const testClient = {
// chat: {
// postMessage: sinon.stub().resolves({}),
// },
// };
// const testAdmins = ["testAdmin"];
// const testObject = {
// message: testMessage,
// client: testClient,
// admins: testAdmins,
// };
// sinon.stub(deduction, "refundDeduction").resolves(true);
// await deduction.respondToRefund(testObject);
// sinon.assert.calledWith(testClient.chat.postMessage, {
// channel: testMessage.channel,
// user: testMessage.user,
// text: "Refund Successfully given",
// });
// });
it("should return a successful refund message to user", async () => {
const testMessage = {
user: "testAdmin",
channel: "testchannel",
text: "@gratibot refund 62171d78b5daaa0011771cfd",
};
const testClient = {
chat: {
postMessage: sinon.stub(),
},
};
const testAdmins = ["testAdmin"];
const testObject = {
message: testMessage,
client: testClient,
admins: testAdmins,
};
sinon.stub(deductionCollection, "findOneAndUpdate").resolves(true);

await deduction.respondToRefund(testObject);
sinon.assert.calledWith(testClient.chat.postMessage, {
channel: testMessage.channel,
user: testMessage.user,
text: "Refund Successfully given",
});
});

it("should return a message informing user that they must be redemption admin", async () => {
const testMessage = {
Expand Down
Loading

0 comments on commit 3041c1c

Please sign in to comment.