Skip to content

Commit

Permalink
services/notification: fix empty snoretoast msgs
Browse files Browse the repository at this point in the history
Fixes #1006
  • Loading branch information
bastimeyer committed May 5, 2024
1 parent 7495380 commit e825f0a
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/app/services/notification/providers/snoretoast.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export default class NotificationProviderSnoreToast {
"-t",
data.title,
"-m",
data.getMessageAsString(),
data.getMessageAsString() || " ",
"-p",
data.icon,
"-id",
Expand Down
75 changes: 75 additions & 0 deletions src/test/tests/services/notification/providers/snoretoast.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,81 @@ module( "services/notification/providers/snoretoast", function( hooks ) {
);
});

test( "Messages", async function( assert ) {
/** @this {TestContextServicesNotificationProviderSnoretoast} */
const { default: NotificationProviderSnoreToast } = this.subject();
this.promiseChildProcessStub.returns( Promise.resolve() );

const inst = new NotificationProviderSnoreToast();
await inst.setup();
this.promiseChildProcessStub.resetHistory();

await inst.notify( new NotificationData({
title: "foo",
message: "bar",
icon: "icon-path",
click: new Function()
}) );
await inst.notify( new NotificationData({
title: "baz",
message: " ",
icon: "icon-path",
click: new Function()
}) );
assert.propEqual(
this.promiseChildProcessStub.args.map( args => args[0] ),
[
[
"C:\\app\\bin\\win64\\snoretoast.exe",
[
"-appID",
"application name",
"-silent",
"-t",
"foo",
"-m",
"bar",
"-p",
"icon-path",
"-id",
"1",
"-pipeName",
"\\\\.\\pipe\\application-name",
"-application",
"C:\\app\\executable"
],
{
"stdio": [ 1 ]
}
],
[
"C:\\app\\bin\\win64\\snoretoast.exe",
[
"-appID",
"application name",
"-silent",
"-t",
"baz",
"-m",
" ",
"-p",
"icon-path",
"-id",
"2",
"-pipeName",
"\\\\.\\pipe\\application-name",
"-application",
"C:\\app\\executable"
],
{
"stdio": [ 1 ]
}
]
],
"Ensures non-empty messages"
);
});

test( "Notify fail and message format", async function( assert ) {
/** @this {TestContextServicesNotificationProviderSnoretoast} */
const { default: NotificationProviderSnoreToast } = this.subject();
Expand Down

0 comments on commit e825f0a

Please sign in to comment.