Skip to content

Commit 5287320

Browse files
dsanders11pull[bot]
authored andcommitted
docs: fix typing of message box type value (#38336)
* docs: fix typing of dialog type value * test: add smoke tests * test: update test
1 parent 7f23af9 commit 5287320

3 files changed

Lines changed: 27 additions & 9 deletions

File tree

‎docs/api/dialog.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ expanding and collapsing the dialog.
223223
* `browserWindow` [BrowserWindow](browser-window.md) (optional)
224224
* `options` Object
225225
* `message` string - Content of the message box.
226-
* `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
227-
`"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
228-
you set an icon using the `"icon"` option. On macOS, both `"warning"` and
229-
`"error"` display the same warning icon.
226+
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or
227+
`warning`. On Windows, `question` displays the same icon as `info`, unless
228+
you set an icon using the `icon` option. On macOS, both `warning` and
229+
`error` display the same warning icon.
230230
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
231231
will result in one button labeled "OK".
232232
* `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
266266
* `browserWindow` [BrowserWindow](browser-window.md) (optional)
267267
* `options` Object
268268
* `message` string - Content of the message box.
269-
* `type` string (optional) - Can be `"none"`, `"info"`, `"error"`, `"question"` or
270-
`"warning"`. On Windows, `"question"` displays the same icon as `"info"`, unless
271-
you set an icon using the `"icon"` option. On macOS, both `"warning"` and
272-
`"error"` display the same warning icon.
269+
* `type` string (optional) - Can be `none`, `info`, `error`, `question` or
270+
`warning`. On Windows, `question` displays the same icon as `info`, unless
271+
you set an icon using the `icon` option. On macOS, both `warning` and
272+
`error` display the same warning icon.
273273
* `buttons` string[] (optional) - Array of texts for buttons. On Windows, an empty array
274274
will result in one button labeled "OK".
275275
* `defaultId` Integer (optional) - Index of the button in the buttons array which will

‎spec/api-dialog-spec.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ describe('dialog module', () => {
9797

9898
it('throws errors when the options are invalid', () => {
9999
expect(() => {
100-
dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type', message: '' });
100+
dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type' as any, message: '' });
101101
}).to.throw(/Invalid message box type/);
102102

103103
expect(() => {

‎spec/ts-smoke/electron/main.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,24 @@ dialog.showOpenDialog(win3, {
503503
console.log(ret);
504504
});
505505

506+
// variants without browserWindow
507+
dialog.showMessageBox({ message: 'test', type: 'warning' });
508+
dialog.showMessageBoxSync({ message: 'test', type: 'error' });
509+
510+
// @ts-expect-error Invalid type value
511+
dialog.showMessageBox({ message: 'test', type: 'foo' });
512+
// @ts-expect-error Invalid type value
513+
dialog.showMessageBoxSync({ message: 'test', type: 'foo' });
514+
515+
// variants with browserWindow
516+
dialog.showMessageBox(win3, { message: 'test', type: 'question' });
517+
dialog.showMessageBoxSync(win3, { message: 'test', type: 'info' });
518+
519+
// @ts-expect-error Invalid type value
520+
dialog.showMessageBox(win3, { message: 'test', type: 'foo' });
521+
// @ts-expect-error Invalid type value
522+
dialog.showMessageBoxSync(win3, { message: 'test', type: 'foo' });
523+
506524
// desktopCapturer
507525
// https://github.com/electron/electron/blob/main/docs/api/desktop-capturer.md
508526

0 commit comments

Comments
 (0)