-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add additional tests for notifyToRest and utils (#28)
* Add additional tests for notifyToRest * Additional tests
- Loading branch information
1 parent
ffad3b5
commit 90f31c4
Showing
5 changed files
with
654 additions
and
615 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,20 @@ | ||
const NotificationService = require('./service'); | ||
const NotificationService = require("./service"); | ||
const { buildNotification } = require("../lib/utils"); | ||
const { postNotification } = require('../lib/notifications'); | ||
const { postNotification } = require("../lib/notifications"); | ||
|
||
module.exports = class NotifyToRest extends NotificationService { | ||
async init() { | ||
|
||
// call NotificationService's init | ||
await super.init(); | ||
|
||
this.on('postNotificationEvent', async function(req) { | ||
const { data } = req; | ||
|
||
try { | ||
await postNotification(data); | ||
} catch (err) { | ||
throw err; | ||
} | ||
}); | ||
this.on("postNotificationEvent", async (req) => await postNotification(req.data)); | ||
} | ||
|
||
async notify(notificationData) { | ||
const notification = buildNotification(notificationData); | ||
|
||
if (notification) { | ||
await this.emit({ event: 'postNotificationEvent', data: notification }); | ||
await this.emit({ event: "postNotificationEvent", data: notification }); | ||
} | ||
} | ||
} | ||
}; |
Oops, something went wrong.