mirror of
https://github.com/louislam/uptime-kuma.git
synced 2024-11-24 07:14:04 +00:00
Merge pull request #1728 from tamasmagyar/test/simplify-discord-unit-tests
test: simplified discord unit tests
This commit is contained in:
commit
fa60672cce
1 changed files with 11 additions and 37 deletions
|
@ -159,7 +159,6 @@ describe("Test genSecret", () => {
|
|||
expect(secret).toContain("A");
|
||||
expect(secret).toContain("9");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("Test reset-password", () => {
|
||||
|
@ -169,6 +168,9 @@ describe("Test reset-password", () => {
|
|||
});
|
||||
|
||||
describe("Test Discord Notification Provider", () => {
|
||||
const hostname = "discord.com";
|
||||
const port = 1337;
|
||||
|
||||
const sendNotification = async (hostname, port, type) => {
|
||||
const discordProvider = new Discord();
|
||||
|
||||
|
@ -191,42 +193,14 @@ describe("Test Discord Notification Provider", () => {
|
|||
);
|
||||
};
|
||||
|
||||
it("should send hostname for dns monitors", async () => {
|
||||
const hostname = "discord.com";
|
||||
await sendNotification(hostname, null, "dns");
|
||||
|
||||
expect(axios.post.mock.lastCall[1].embeds[0].fields[1].value).toBe(
|
||||
hostname
|
||||
);
|
||||
});
|
||||
|
||||
it("should send hostname for ping monitors", async () => {
|
||||
const hostname = "discord.com";
|
||||
await sendNotification(hostname, null, "ping");
|
||||
|
||||
expect(axios.post.mock.lastCall[1].embeds[0].fields[1].value).toBe(
|
||||
hostname
|
||||
);
|
||||
expect(axios.post.mock.lastCall[1].embeds[0].fields[1].value).toBe(hostname);
|
||||
});
|
||||
|
||||
it("should send hostname for port monitors", async () => {
|
||||
const hostname = "discord.com";
|
||||
const port = 1337;
|
||||
await sendNotification(hostname, port, "port");
|
||||
|
||||
expect(axios.post.mock.lastCall[1].embeds[0].fields[1].value).toBe(
|
||||
`${hostname}:${port}`
|
||||
);
|
||||
});
|
||||
|
||||
it("should send hostname for steam monitors", async () => {
|
||||
const hostname = "discord.com";
|
||||
const port = 1337;
|
||||
await sendNotification(hostname, port, "steam");
|
||||
|
||||
expect(axios.post.mock.lastCall[1].embeds[0].fields[1].value).toBe(
|
||||
`${hostname}:${port}`
|
||||
);
|
||||
it.each([ "dns", "port", "steam" ])("should send hostname for %p monitors", async (type) => {
|
||||
await sendNotification(hostname, port, type);
|
||||
expect(axios.post.mock.lastCall[1].embeds[0].fields[1].value).toBe(`${hostname}:${port}`);
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue