fix: Correctly handle if cb is undefined in wrapChildPromise (#16277)

This commit is contained in:
Jennifer Shehane
2021-05-04 13:49:14 -05:00
committed by GitHub
parent a73adf2b49
commit 41d3d50822
2 changed files with 6 additions and 6 deletions
+2 -2
View File
@@ -40,10 +40,10 @@ module.exports = {
}
},
wrapChildPromise (ipc, invoke, ids, args = [], cb) {
wrapChildPromise (ipc, invoke, ids, args = []) {
return Promise.try(() => {
return invoke(ids.eventId, args)
}).then(cb)
})
.then((value) => {
// undefined is coerced into null when sent over ipc, but we need
// to differentiate between them for 'task' event
@@ -86,7 +86,7 @@ describe('lib/plugins/util', () => {
expect(util.wrapChildPromise(this.ipc, this.invoke, this.ids)).to.be.an.instanceOf(Promise)
})
it('sends \'promise:fulfilled:{invocatationId}\' with value when promise resolves', function () {
it('sends "promise:fulfilled:{invocatationId}" with value when promise resolves', function () {
this.invoke.resolves('value')
return util.wrapChildPromise(this.ipc, this.invoke, this.ids).then(() => {
@@ -102,7 +102,7 @@ describe('lib/plugins/util', () => {
})
})
it('sends \'promise:fulfilled:{invocatationId}\' with error when promise rejects', function () {
it('sends "promise:fulfilled:{invocatationId}" with error when promise rejects', function () {
const err = new Error('fail')
err.code = 'ERM_DUN_FAILED'
@@ -138,7 +138,7 @@ describe('lib/plugins/util', () => {
expect(util.wrapParentPromise(this.ipc, 0, this.callback)).to.be.an.instanceOf(Promise)
})
it('resolves the promise when \'promise:fulfilled:{invocationId}\' event is received without error', function () {
it('resolves the promise when "promise:fulfilled:{invocationId}" event is received without error', function () {
const promise = util.wrapParentPromise(this.ipc, 0, this.callback)
const invocationId = this.callback.lastCall.args[0]
@@ -160,7 +160,7 @@ describe('lib/plugins/util', () => {
})
})
it('rejects the promise when \'promise:fulfilled:{invocationId}\' event is received with error', function () {
it('rejects the promise when "promise:fulfilled:{invocationId}" event is received with error', function () {
const promise = util.wrapParentPromise(this.ipc, 0, this.callback)
const invocationId = this.callback.lastCall.args[0]
const err = {