Skip to content

Commit 1fd6238

Browse files
committed
* Revert test to work as before * Change toaster back to sync function, that uses callback
1 parent e60b2d1 commit 1fd6238

File tree

2 files changed

+22
-20
lines changed

2 files changed

+22
-20
lines changed

notifiers/toaster.js

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function getPipeName() {
4949
return `${PIPE_PATH_PREFIX}${PIPE_NAME}-${uuid()}`;
5050
}
5151

52-
WindowsToaster.prototype.notify = async function(options, callback) {
52+
WindowsToaster.prototype.notify = function(options, callback) {
5353
options = utils.clone(options || {});
5454
callback = callback || noop;
5555
var is64Bit = os.arch() === 'x64';
@@ -122,22 +122,24 @@ WindowsToaster.prototype.notify = async function(options, callback) {
122122
}
123123

124124
// Add pipeName option, to get the output
125-
resultBuffer = await utils.createNamedPipe(namedPipe);
126-
options.pipeName = namedPipe;
127-
128-
options = utils.mapToWin8(options);
129-
var argsList = utils.constructArgumentList(options, {
130-
explicitTrue: true,
131-
wrapper: '',
132-
keepNewlines: true,
133-
noEscape: true
125+
utils.createNamedPipe(namedPipe).then(out => {
126+
resultBuffer = out;
127+
options.pipeName = namedPipe;
128+
129+
options = utils.mapToWin8(options);
130+
var argsList = utils.constructArgumentList(options, {
131+
explicitTrue: true,
132+
wrapper: '',
133+
keepNewlines: true,
134+
noEscape: true
135+
});
136+
137+
var notifierWithArch = notifier + '-x' + (is64Bit ? '64' : '86') + '.exe';
138+
utils.fileCommand(
139+
this.options.customPath || notifierWithArch,
140+
argsList,
141+
actionJackedCallback
142+
);
134143
});
135-
136-
var notifierWithArch = notifier + '-x' + (is64Bit ? '64' : '86') + '.exe';
137-
utils.fileCommand(
138-
this.options.customPath || notifierWithArch,
139-
argsList,
140-
actionJackedCallback
141-
);
142144
return this;
143145
};

test/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ describe('constructors', function() {
1010
expect(notifier.notify({ title: 'My notification' }, cb)).toBeTruthy();
1111
});
1212

13-
it('should throw error when second parameter is not a function', async () => {
13+
it('should throw error when second parameter is not a function', function() {
1414
var wrongParamOne = 200;
1515
var wrongParamTwo = 'meaningless string';
1616
var data = { title: 'My notification' };
1717

1818
var base = notifier.notify.bind(notifier, data);
19-
await expect(base.bind(notifier, wrongParamOne)()).rejects.toThrowError(
19+
expect(base.bind(notifier, wrongParamOne)).toThrowError(
2020
/^The second argument/
2121
);
22-
await expect(base.bind(notifier, wrongParamTwo)()).rejects.toThrowError(
22+
expect(base.bind(notifier, wrongParamTwo)).toThrowError(
2323
/^The second argument/
2424
);
2525
});

0 commit comments

Comments
 (0)