Merge pull request #8187 from electron/optional-buttons
Allow buttons to be optional in 'showMessageBox'
This commit is contained in:
commit
cb7715a572
2 changed files with 7 additions and 7 deletions
|
@ -61,9 +61,7 @@ module.exports = {
|
||||||
|
|
||||||
if (properties == null) {
|
if (properties == null) {
|
||||||
properties = ['openFile']
|
properties = ['openFile']
|
||||||
}
|
} else if (!Array.isArray(properties)) {
|
||||||
|
|
||||||
if (!Array.isArray(properties)) {
|
|
||||||
throw new TypeError('Properties must be an array')
|
throw new TypeError('Properties must be an array')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,7 +165,9 @@ module.exports = {
|
||||||
throw new TypeError('Invalid message box type')
|
throw new TypeError('Invalid message box type')
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Array.isArray(buttons)) {
|
if (buttons == null) {
|
||||||
|
buttons = []
|
||||||
|
} else if (!Array.isArray(buttons)) {
|
||||||
throw new TypeError('Buttons must be an array')
|
throw new TypeError('Buttons must be an array')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,15 +49,15 @@ describe('dialog module', () => {
|
||||||
}, /Buttons must be an array/)
|
}, /Buttons must be an array/)
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
dialog.showMessageBox({title: 300, buttons: ['OK']})
|
dialog.showMessageBox({title: 300})
|
||||||
}, /Title must be a string/)
|
}, /Title must be a string/)
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
dialog.showMessageBox({message: [], buttons: ['OK']})
|
dialog.showMessageBox({message: []})
|
||||||
}, /Message must be a string/)
|
}, /Message must be a string/)
|
||||||
|
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
dialog.showMessageBox({detail: 3.14, buttons: ['OK']})
|
dialog.showMessageBox({detail: 3.14})
|
||||||
}, /Detail must be a string/)
|
}, /Detail must be a string/)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue