forked from asticode/go-astilectron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
notification_test.go
30 lines (26 loc) · 1.19 KB
/
notification_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package astilectron
import (
"context"
"testing"
"github.com/asticode/go-astikit"
)
func TestNotification_Actions(t *testing.T) {
// Init
var d = newDispatcher()
var i = newIdentifier()
var wrt = &mockedWriter{}
var w = newWriter(wrt, &logger{})
var n = newNotification(context.Background(), &NotificationOptions{
Body: "body",
HasReply: astikit.BoolPtr(true),
Icon: "/path/to/icon",
ReplyPlaceholder: "placeholder",
Silent: astikit.BoolPtr(true),
Sound: "sound",
Subtitle: "subtitle",
Title: "title",
}, true, d, i, w)
// Actions
testObjectAction(t, func() error { return n.Create() }, n.object, wrt, "{\"name\":\""+eventNameNotificationCmdCreate+"\",\"targetID\":\""+n.id+"\",\"notificationOptions\":{\"body\":\"body\",\"hasReply\":true,\"icon\":\"/path/to/icon\",\"replyPlaceholder\":\"placeholder\",\"silent\":true,\"sound\":\"sound\",\"subtitle\":\"subtitle\",\"title\":\"title\"}}\n", EventNameNotificationEventCreated)
testObjectAction(t, func() error { return n.Show() }, n.object, wrt, "{\"name\":\""+eventNameNotificationCmdShow+"\",\"targetID\":\""+n.id+"\"}\n", EventNameNotificationEventShown)
}