Browse Source

fix #859 and update tests to match

deefdragon/notif-tests
Jeffrey Koehler 3 years ago
parent
commit
782c943f93
  1. 2
      server/notification-providers/dingding.js
  2. 6
      server/notification-providers/dingding.spec.js

2
server/notification-providers/dingding.js

@ -14,7 +14,7 @@ class DingDing extends NotificationProvider {
msgtype: "markdown", msgtype: "markdown",
markdown: { markdown: {
title: monitorJSON["name"], title: monitorJSON["name"],
text: `## [${this.statusToString(heartbeatJSON["status"])}] \n > ${heartbeatJSON["msg"]} \n > Time(UTC):${heartbeatJSON["time"]}`, text: `## [${this.statusToString(heartbeatJSON["status"])}] ${monitorJSON["name"]}\n > ${heartbeatJSON["msg"]} \n > Time(UTC):${heartbeatJSON["time"]}`,
} }
}; };
if (await this.sendToDingDing(notification, params)) { if (await this.sendToDingDing(notification, params)) {

6
server/notification-providers/dingding.spec.js

@ -53,7 +53,7 @@ describe("notification to act properly on send", () => {
let res = await notif.send(notificationConf, msg, monitorConf, heartbeatConf); let res = await notif.send(notificationConf, msg, monitorConf, heartbeatConf);
expect(axios).toHaveBeenCalledWith({ expect(axios).toHaveBeenCalledWith({
data: "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"testing\",\"text\":\"## [UP] \\n > some message \\n > Time(UTC):example time\"}}", data: "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"testing\",\"text\":\"## [UP] testing\\n > some message \\n > Time(UTC):example time\"}}",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
@ -146,7 +146,7 @@ describe("notification to act properly on error", () => {
} }
expect(axios).toHaveBeenCalledWith({ expect(axios).toHaveBeenCalledWith({
data: "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"testing\",\"text\":\"## [UP] \\n > some message \\n > Time(UTC):example time\"}}", data: "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"testing\",\"text\":\"## [UP] testing\\n > some message \\n > Time(UTC):example time\"}}",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
@ -194,7 +194,7 @@ describe("notification to get proper data from Notification.send", () => {
expect(res).toBe("Sent Successfully."); expect(res).toBe("Sent Successfully.");
expect(axios).toHaveBeenCalledWith({ expect(axios).toHaveBeenCalledWith({
data: "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"testing\",\"text\":\"## [UP] \\n > some message \\n > Time(UTC):example time\"}}", data: "{\"msgtype\":\"markdown\",\"markdown\":{\"title\":\"testing\",\"text\":\"## [UP] testing\\n > some message \\n > Time(UTC):example time\"}}",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },

Loading…
Cancel
Save