From 1fd62383531f7defe6647ce2a0ea013abe6e7493 Mon Sep 17 00:00:00 2001 From: Yoav Vainrich Date: Wed, 30 Oct 2019 00:17:44 +0200 Subject: [PATCH] Issue #193 * Revert test to work as before * Change toaster back to sync function, that uses callback --- notifiers/toaster.js | 36 +++++++++++++++++++----------------- test/index.js | 6 +++--- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/notifiers/toaster.js b/notifiers/toaster.js index 15e89ef..4269d0b 100644 --- a/notifiers/toaster.js +++ b/notifiers/toaster.js @@ -49,7 +49,7 @@ function getPipeName() { return `${PIPE_PATH_PREFIX}${PIPE_NAME}-${uuid()}`; } -WindowsToaster.prototype.notify = async function(options, callback) { +WindowsToaster.prototype.notify = function(options, callback) { options = utils.clone(options || {}); callback = callback || noop; var is64Bit = os.arch() === 'x64'; @@ -122,22 +122,24 @@ WindowsToaster.prototype.notify = async function(options, callback) { } // Add pipeName option, to get the output - resultBuffer = await utils.createNamedPipe(namedPipe); - options.pipeName = namedPipe; - - options = utils.mapToWin8(options); - var argsList = utils.constructArgumentList(options, { - explicitTrue: true, - wrapper: '', - keepNewlines: true, - noEscape: true + utils.createNamedPipe(namedPipe).then(out => { + resultBuffer = out; + options.pipeName = namedPipe; + + options = utils.mapToWin8(options); + var argsList = utils.constructArgumentList(options, { + explicitTrue: true, + wrapper: '', + keepNewlines: true, + noEscape: true + }); + + var notifierWithArch = notifier + '-x' + (is64Bit ? '64' : '86') + '.exe'; + utils.fileCommand( + this.options.customPath || notifierWithArch, + argsList, + actionJackedCallback + ); }); - - var notifierWithArch = notifier + '-x' + (is64Bit ? '64' : '86') + '.exe'; - utils.fileCommand( - this.options.customPath || notifierWithArch, - argsList, - actionJackedCallback - ); return this; }; diff --git a/test/index.js b/test/index.js index 99f3170..cb4f441 100644 --- a/test/index.js +++ b/test/index.js @@ -10,16 +10,16 @@ describe('constructors', function() { expect(notifier.notify({ title: 'My notification' }, cb)).toBeTruthy(); }); - it('should throw error when second parameter is not a function', async () => { + it('should throw error when second parameter is not a function', function() { var wrongParamOne = 200; var wrongParamTwo = 'meaningless string'; var data = { title: 'My notification' }; var base = notifier.notify.bind(notifier, data); - await expect(base.bind(notifier, wrongParamOne)()).rejects.toThrowError( + expect(base.bind(notifier, wrongParamOne)).toThrowError( /^The second argument/ ); - await expect(base.bind(notifier, wrongParamTwo)()).rejects.toThrowError( + expect(base.bind(notifier, wrongParamTwo)).toThrowError( /^The second argument/ ); });