docs: fix typing of message box type value (#38336)
* docs: fix typing of dialog type value * test: add smoke tests * test: update test
This commit is contained in:
parent
a22635bd9f
commit
e138f5f915
3 changed files with 27 additions and 9 deletions
|
@ -223,10 +223,10 @@ expanding and collapsing the dialog.
|
||||||
* `browserWindow` [BrowserWindow](browser-window.md) (optional)
|
* `browserWindow` [BrowserWindow](browser-window.md) (optional)
|
||||||
* `options` Object
|
* `options` Object
|
||||||
* `message` string - Content of the message box.
|
* `message` string - Content of the message box.
|
||||||
* `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
|
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or
|
||||||
`"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
|
`warning`. On Windows, `question` displays the same icon as `info`, unless
|
||||||
you set an icon using the `"icon"` option. On macOS, both `"warning"` and
|
you set an icon using the `icon` option. On macOS, both `warning` and
|
||||||
`"error"` display the same warning icon.
|
`error` display the same warning icon.
|
||||||
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
|
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
|
||||||
will result in one button labeled "OK".
|
will result in one button labeled "OK".
|
||||||
* `defaultId` Integer (optional) - Index of the button in the buttons array which will
|
* `defaultId` Integer (optional) - Index of the button in the buttons array which will
|
||||||
|
@ -266,10 +266,10 @@ If `browserWindow` is not shown dialog will not be attached to it. In such case
|
||||||
* `browserWindow` [BrowserWindow](browser-window.md) (optional)
|
* `browserWindow` [BrowserWindow](browser-window.md) (optional)
|
||||||
* `options` Object
|
* `options` Object
|
||||||
* `message` string - Content of the message box.
|
* `message` string - Content of the message box.
|
||||||
* `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
|
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or
|
||||||
`"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
|
`warning`. On Windows, `question` displays the same icon as `info`, unless
|
||||||
you set an icon using the `"icon"` option. On macOS, both `"warning"` and
|
you set an icon using the `icon` option. On macOS, both `warning` and
|
||||||
`"error"` display the same warning icon.
|
`error` display the same warning icon.
|
||||||
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
|
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
|
||||||
will result in one button labeled "OK".
|
will result in one button labeled "OK".
|
||||||
* `defaultId` Integer (optional) - Index of the button in the buttons array which will
|
* `defaultId` Integer (optional) - Index of the button in the buttons array which will
|
||||||
|
|
|
@ -97,7 +97,7 @@ describe('dialog module', () => {
|
||||||
|
|
||||||
it('throws errors when the options are invalid', () => {
|
it('throws errors when the options are invalid', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type', message: '' });
|
dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type' as any, message: '' });
|
||||||
}).to.throw(/Invalid message box type/);
|
}).to.throw(/Invalid message box type/);
|
||||||
|
|
||||||
expect(() => {
|
expect(() => {
|
||||||
|
|
|
@ -503,6 +503,24 @@ dialog.showOpenDialog(win3, {
|
||||||
console.log(ret);
|
console.log(ret);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// variants without browserWindow
|
||||||
|
dialog.showMessageBox({ message: 'test', type: 'warning' });
|
||||||
|
dialog.showMessageBoxSync({ message: 'test', type: 'error' });
|
||||||
|
|
||||||
|
// @ts-expect-error Invalid type value
|
||||||
|
dialog.showMessageBox({ message: 'test', type: 'foo' });
|
||||||
|
// @ts-expect-error Invalid type value
|
||||||
|
dialog.showMessageBoxSync({ message: 'test', type: 'foo' });
|
||||||
|
|
||||||
|
// variants with browserWindow
|
||||||
|
dialog.showMessageBox(win3, { message: 'test', type: 'question' });
|
||||||
|
dialog.showMessageBoxSync(win3, { message: 'test', type: 'info' });
|
||||||
|
|
||||||
|
// @ts-expect-error Invalid type value
|
||||||
|
dialog.showMessageBox(win3, { message: 'test', type: 'foo' });
|
||||||
|
// @ts-expect-error Invalid type value
|
||||||
|
dialog.showMessageBoxSync(win3, { message: 'test', type: 'foo' });
|
||||||
|
|
||||||
// desktopCapturer
|
// desktopCapturer
|
||||||
// https://github.com/electron/electron/blob/main/docs/api/desktop-capturer.md
|
// https://github.com/electron/electron/blob/main/docs/api/desktop-capturer.md
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue