build: enable JS semicolons (#22783)
This commit is contained in:
parent
24e21467b9
commit
5d657dece4
354 changed files with 21512 additions and 21510 deletions
|
@ -1,155 +1,155 @@
|
|||
import { expect } from 'chai'
|
||||
import { dialog, BrowserWindow } from 'electron'
|
||||
import { closeAllWindows } from './window-helpers'
|
||||
import { ifit } from './spec-helpers'
|
||||
import { expect } from 'chai';
|
||||
import { dialog, BrowserWindow } from 'electron';
|
||||
import { closeAllWindows } from './window-helpers';
|
||||
import { ifit } from './spec-helpers';
|
||||
|
||||
describe('dialog module', () => {
|
||||
describe('showOpenDialog', () => {
|
||||
afterEach(closeAllWindows)
|
||||
afterEach(closeAllWindows);
|
||||
ifit(process.platform !== 'win32')('should not throw for valid cases', () => {
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ title: 'i am title' })
|
||||
}).to.not.throw()
|
||||
dialog.showOpenDialog({ title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
|
||||
expect(() => {
|
||||
const w = new BrowserWindow()
|
||||
dialog.showOpenDialog(w, { title: 'i am title' })
|
||||
}).to.not.throw()
|
||||
})
|
||||
const w = new BrowserWindow();
|
||||
dialog.showOpenDialog(w, { title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ properties: false as any })
|
||||
}).to.throw(/Properties must be an array/)
|
||||
dialog.showOpenDialog({ properties: false as any });
|
||||
}).to.throw(/Properties must be an array/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ title: 300 as any })
|
||||
}).to.throw(/Title must be a string/)
|
||||
dialog.showOpenDialog({ title: 300 as any });
|
||||
}).to.throw(/Title must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ buttonLabel: [] as any })
|
||||
}).to.throw(/Button label must be a string/)
|
||||
dialog.showOpenDialog({ buttonLabel: [] as any });
|
||||
}).to.throw(/Button label must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ defaultPath: {} as any })
|
||||
}).to.throw(/Default path must be a string/)
|
||||
dialog.showOpenDialog({ defaultPath: {} as any });
|
||||
}).to.throw(/Default path must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showOpenDialog({ message: {} as any })
|
||||
}).to.throw(/Message must be a string/)
|
||||
})
|
||||
})
|
||||
dialog.showOpenDialog({ message: {} as any });
|
||||
}).to.throw(/Message must be a string/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showSaveDialog', () => {
|
||||
afterEach(closeAllWindows)
|
||||
afterEach(closeAllWindows);
|
||||
ifit(process.platform !== 'win32')('should not throw for valid cases', () => {
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ title: 'i am title' })
|
||||
}).to.not.throw()
|
||||
dialog.showSaveDialog({ title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
|
||||
expect(() => {
|
||||
const w = new BrowserWindow()
|
||||
dialog.showSaveDialog(w, { title: 'i am title' })
|
||||
}).to.not.throw()
|
||||
})
|
||||
const w = new BrowserWindow();
|
||||
dialog.showSaveDialog(w, { title: 'i am title' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ title: 300 as any })
|
||||
}).to.throw(/Title must be a string/)
|
||||
dialog.showSaveDialog({ title: 300 as any });
|
||||
}).to.throw(/Title must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ buttonLabel: [] as any })
|
||||
}).to.throw(/Button label must be a string/)
|
||||
dialog.showSaveDialog({ buttonLabel: [] as any });
|
||||
}).to.throw(/Button label must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ defaultPath: {} as any })
|
||||
}).to.throw(/Default path must be a string/)
|
||||
dialog.showSaveDialog({ defaultPath: {} as any });
|
||||
}).to.throw(/Default path must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ message: {} as any })
|
||||
}).to.throw(/Message must be a string/)
|
||||
dialog.showSaveDialog({ message: {} as any });
|
||||
}).to.throw(/Message must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showSaveDialog({ nameFieldLabel: {} as any })
|
||||
}).to.throw(/Name field label must be a string/)
|
||||
})
|
||||
})
|
||||
dialog.showSaveDialog({ nameFieldLabel: {} as any });
|
||||
}).to.throw(/Name field label must be a string/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showMessageBox', () => {
|
||||
afterEach(closeAllWindows)
|
||||
afterEach(closeAllWindows);
|
||||
|
||||
// parentless message boxes are synchronous on macOS
|
||||
// dangling message boxes on windows cause a DCHECK: https://cs.chromium.org/chromium/src/base/win/message_window.cc?l=68&rcl=7faa4bf236a866d007dc5672c9ce42660e67a6a6
|
||||
ifit(process.platform !== 'darwin' && process.platform !== 'win32')('should not throw for a parentless message box', () => {
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ message: 'i am message' })
|
||||
}).to.not.throw()
|
||||
})
|
||||
dialog.showMessageBox({ message: 'i am message' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
ifit(process.platform !== 'win32')('should not throw for valid cases', () => {
|
||||
expect(() => {
|
||||
const w = new BrowserWindow()
|
||||
dialog.showMessageBox(w, { message: 'i am message' })
|
||||
}).to.not.throw()
|
||||
})
|
||||
const w = new BrowserWindow();
|
||||
dialog.showMessageBox(w, { message: 'i am message' });
|
||||
}).to.not.throw();
|
||||
});
|
||||
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type', message: '' })
|
||||
}).to.throw(/Invalid message box type/)
|
||||
dialog.showMessageBox(undefined as any, { type: 'not-a-valid-type', message: '' });
|
||||
}).to.throw(/Invalid message box type/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox(null as any, { buttons: false as any, message: '' })
|
||||
}).to.throw(/Buttons must be an array/)
|
||||
dialog.showMessageBox(null as any, { buttons: false as any, message: '' });
|
||||
}).to.throw(/Buttons must be an array/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ title: 300 as any, message: '' })
|
||||
}).to.throw(/Title must be a string/)
|
||||
dialog.showMessageBox({ title: 300 as any, message: '' });
|
||||
}).to.throw(/Title must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ message: [] as any })
|
||||
}).to.throw(/Message must be a string/)
|
||||
dialog.showMessageBox({ message: [] as any });
|
||||
}).to.throw(/Message must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ detail: 3.14 as any, message: '' })
|
||||
}).to.throw(/Detail must be a string/)
|
||||
dialog.showMessageBox({ detail: 3.14 as any, message: '' });
|
||||
}).to.throw(/Detail must be a string/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showMessageBox({ checkboxLabel: false as any, message: '' })
|
||||
}).to.throw(/checkboxLabel must be a string/)
|
||||
})
|
||||
})
|
||||
dialog.showMessageBox({ checkboxLabel: false as any, message: '' });
|
||||
}).to.throw(/checkboxLabel must be a string/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showErrorBox', () => {
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
(dialog.showErrorBox as any)()
|
||||
}).to.throw(/Insufficient number of arguments/)
|
||||
(dialog.showErrorBox as any)();
|
||||
}).to.throw(/Insufficient number of arguments/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showErrorBox(3 as any, 'four')
|
||||
}).to.throw(/Error processing argument at index 0/)
|
||||
dialog.showErrorBox(3 as any, 'four');
|
||||
}).to.throw(/Error processing argument at index 0/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showErrorBox('three', 4 as any)
|
||||
}).to.throw(/Error processing argument at index 1/)
|
||||
})
|
||||
})
|
||||
dialog.showErrorBox('three', 4 as any);
|
||||
}).to.throw(/Error processing argument at index 1/);
|
||||
});
|
||||
});
|
||||
|
||||
describe('showCertificateTrustDialog', () => {
|
||||
it('throws errors when the options are invalid', () => {
|
||||
expect(() => {
|
||||
(dialog.showCertificateTrustDialog as any)()
|
||||
}).to.throw(/options must be an object/)
|
||||
(dialog.showCertificateTrustDialog as any)();
|
||||
}).to.throw(/options must be an object/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showCertificateTrustDialog({} as any)
|
||||
}).to.throw(/certificate must be an object/)
|
||||
dialog.showCertificateTrustDialog({} as any);
|
||||
}).to.throw(/certificate must be an object/);
|
||||
|
||||
expect(() => {
|
||||
dialog.showCertificateTrustDialog({ certificate: {} as any, message: false as any })
|
||||
}).to.throw(/message must be a string/)
|
||||
})
|
||||
})
|
||||
})
|
||||
dialog.showCertificateTrustDialog({ certificate: {} as any, message: false as any });
|
||||
}).to.throw(/message must be a string/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue