Skip to content

Commit

Permalink
2 pass
Browse files Browse the repository at this point in the history
  • Loading branch information
Panizghi committed Jan 14, 2024
1 parent ba24245 commit dc21a6c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/utils/slack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ describe("slack.ts", () => {
await slack.postMessage(mockWebClient, channel, text);
throw new Error("Expected the promise to reject, but it resolved.");
} catch (error) {
expect(error.message).toBeDefined();
expect(error.message).toEqual("Message text is empty.");
}
});
Expand All @@ -70,6 +71,7 @@ describe("slack.ts", () => {
expect(error.message).toEqual("Invalid channel object.");
}
});

it("posts a message successfully", async () => {
const mockResponse: ChatPostMessageResponse = {
ok: true,
Expand All @@ -81,7 +83,7 @@ describe("slack.ts", () => {
mockResponse,
);

const channelId = "mockChannel";
const channelId = "mockChannelId";
const text = "Hello, Slack!";

try {
Expand All @@ -93,14 +95,13 @@ describe("slack.ts", () => {

const result = await slack.postMessage(mockWebClient, channel, text);

console.log(result);
expect(mockWebClient.chat.postMessage).toHaveBeenCalledWith({
channel: channelId,
text: text,
});
expect(result).toEqual(mockResponse);
} catch (error) {
throw new Error(error);
throw error;
}
});

Expand All @@ -121,8 +122,7 @@ describe("slack.ts", () => {
await slack.postMessage(mockWebClient, channel, text);
throw new Error("Expected the promise to reject, but it resolved.");
} catch (error) {
//console.error(error);
throw error;
expect(error.message).toEqual(`Failed to post message to channel ${channelId} with error ${errorMessage}`);
}
});
});
Expand Down

0 comments on commit dc21a6c

Please sign in to comment.