Skip to content

Commit

Permalink
* Fix use of customPath passed to constructor
Browse files Browse the repository at this point in the history
* Added 2 unit tests
  • Loading branch information
yoavain committed Feb 1, 2022
1 parent 52ad27b commit e79b391
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 e79b391

Please sign in to comment.