Skip to content

Commit

Permalink
Issue mikaelbr#193
Browse files Browse the repository at this point in the history
* Revert test to work as before
* Change toaster back to sync function, that uses callback
  • Loading branch information
yoavain committed Oct 29, 2019
1 parent e60b2d1 commit 1fd6238
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 20 deletions.
36 changes: 19 additions & 17 deletions notifiers/toaster.js
Expand Up @@ -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';
Expand Down Expand Up @@ -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;
};
6 changes: 3 additions & 3 deletions test/index.js
Expand Up @@ -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/
);
});
Expand Down

0 comments on commit 1fd6238

Please sign in to comment.