Skip to content

Commit

Permalink
Merge pull request #392 from yoavain/fix-custom-path-from-constructor
Browse files Browse the repository at this point in the history
Fix issue #377: Fix customPath option in WindowsToaster constructor
  • Loading branch information
mikaelbr authored Feb 1, 2022
2 parents 52ad27b + e79b391 commit a17b196
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion notifiers/toaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function notifyRaw(options, callback) {
resultBuffer = out;
options.pipeName = server.namedPipe;

const localNotifier = options.customPath ||
const localNotifier = options.customPath || this.options.customPath ||
(notifier + '-x' + (is64Bit ? '64' : '86') + '.exe');

options = utils.mapToWin8(options);
Expand Down
43 changes: 43 additions & 0 deletions test/toaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,4 +329,47 @@ describe('WindowsToaster', function () {
actions: ['Ok', 'Cancel'],
});
});

it('should call custom notifier when customPath is passed via message', (done) => {
utils.fileCommand = function (notifier, argsList, callback) {
expect(notifier).toEqual('/test/customPath/snoretoast-x64.exe');
done();
};

const notifier = new Notify();

notifier.notify({
title: 'Heya',
message: 'foo bar',
extra: 'dsakdsa',
foo: 'bar',
close: 123,
bar: true,
id: 1337,
sound: 'Notification.IM',
customPath: '/test/customPath/snoretoast-x64.exe',
actions: ['Ok', 'Cancel'],
});
});

it('should call custom notifier when customPath is passed via constructor', (done) => {
utils.fileCommand = function (notifier, argsList, callback) {
expect(notifier).toEqual('/test/customPath/snoretoast-x64.exe');
done();
};

const notifier = new Notify({ customPath: '/test/customPath/snoretoast-x64.exe' });

notifier.notify({
title: 'Heya',
message: 'foo bar',
extra: 'dsakdsa',
foo: 'bar',
close: 123,
bar: true,
id: 1337,
sound: 'Notification.IM',
actions: ['Ok', 'Cancel'],
});
});
});

0 comments on commit a17b196

Please sign in to comment.