2016-12-02 01:15:05 +03:00
|
|
|
const assert = require('assert')
|
|
|
|
const {dialog} = require('electron').remote
|
|
|
|
|
|
|
|
describe('dialog module', () => {
|
|
|
|
describe('showOpenDialog', () => {
|
|
|
|
it('throws errors when the options are invalid', () => {
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showOpenDialog({properties: false})
|
|
|
|
}, /Properties must be an array/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showOpenDialog({title: 300})
|
|
|
|
}, /Title must be a string/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showOpenDialog({buttonLabel: []})
|
2016-12-02 01:16:33 +03:00
|
|
|
}, /Button label must be a string/)
|
2016-12-02 01:15:05 +03:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showOpenDialog({defaultPath: {}})
|
|
|
|
}, /Default path must be a string/)
|
2017-02-09 16:23:02 +03:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showOpenDialog({message: {}})
|
|
|
|
}, /Message must be a string/)
|
2016-12-02 01:15:05 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('showSaveDialog', () => {
|
|
|
|
it('throws errors when the options are invalid', () => {
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showSaveDialog({title: 300})
|
|
|
|
}, /Title must be a string/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showSaveDialog({buttonLabel: []})
|
2016-12-02 01:16:33 +03:00
|
|
|
}, /Button label must be a string/)
|
2016-12-02 01:15:05 +03:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showSaveDialog({defaultPath: {}})
|
|
|
|
}, /Default path must be a string/)
|
2017-02-09 16:23:02 +03:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showSaveDialog({message: {}})
|
|
|
|
}, /Message must be a string/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showSaveDialog({nameFieldLabel: {}})
|
|
|
|
}, /Name field label must be a string/)
|
2016-12-02 01:15:05 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('showMessageBox', () => {
|
|
|
|
it('throws errors when the options are invalid', () => {
|
|
|
|
assert.throws(() => {
|
2016-12-13 03:25:08 +03:00
|
|
|
dialog.showMessageBox(undefined, {type: 'not-a-valid-type'})
|
2016-12-02 01:15:05 +03:00
|
|
|
}, /Invalid message box type/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
2016-12-13 03:25:08 +03:00
|
|
|
dialog.showMessageBox(null, {buttons: false})
|
2016-12-02 01:15:05 +03:00
|
|
|
}, /Buttons must be an array/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
2016-12-12 21:05:01 +03:00
|
|
|
dialog.showMessageBox({title: 300})
|
2016-12-02 01:15:05 +03:00
|
|
|
}, /Title must be a string/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
2016-12-12 21:05:01 +03:00
|
|
|
dialog.showMessageBox({message: []})
|
2016-12-02 01:15:05 +03:00
|
|
|
}, /Message must be a string/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
2016-12-12 21:05:01 +03:00
|
|
|
dialog.showMessageBox({detail: 3.14})
|
2016-12-02 01:15:05 +03:00
|
|
|
}, /Detail must be a string/)
|
2017-02-06 18:35:36 +03:00
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showMessageBox({checkboxLabel: false})
|
|
|
|
}, /checkboxLabel must be a string/)
|
2016-12-02 01:15:05 +03:00
|
|
|
})
|
|
|
|
})
|
|
|
|
|
|
|
|
describe('showErrorBox', () => {
|
|
|
|
it('throws errors when the options are invalid', () => {
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showErrorBox()
|
|
|
|
}, /Insufficient number of arguments/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showErrorBox(3, 'four')
|
|
|
|
}, /Error processing argument at index 0/)
|
|
|
|
|
|
|
|
assert.throws(() => {
|
|
|
|
dialog.showErrorBox('three', 4)
|
|
|
|
}, /Error processing argument at index 1/)
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|