spec: fix conditions for some tests (#23489)

This commit is contained in:
Alexey Kuzmin 2020-05-11 03:46:45 +02:00 committed by GitHub
parent 6114518463
commit dc3de49a08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View file

@ -11,6 +11,7 @@ import { emittedOnce } from './events-helpers';
import { ifit, ifdescribe } from './spec-helpers';
import { closeWindow, closeAllWindows } from './window-helpers';
const features = process.electronBinding('features');
const fixtures = path.resolve(__dirname, '..', 'spec', 'fixtures');
// Is the display's scale factor possibly causing rounding of pixel coordinate
@ -720,7 +721,7 @@ describe('BrowserWindow module', () => {
});
});
describe('BrowserWindow.moveAbove(mediaSourceId)', () => {
ifdescribe(features.isDesktopCapturerEnabled())('BrowserWindow.moveAbove(mediaSourceId)', () => {
it('should throw an exception if wrong formatting', async () => {
const fakeSourceIds = [
'none', 'screen:0', 'window:fake', 'window:1234', 'foobar:1:2'
@ -731,6 +732,7 @@ describe('BrowserWindow module', () => {
}).to.throw(/Invalid media source id/);
});
});
it('should throw an exception if wrong type', async () => {
const fakeSourceIds = [null as any, 123 as any];
fakeSourceIds.forEach((sourceId) => {
@ -739,6 +741,7 @@ describe('BrowserWindow module', () => {
}).to.throw(/Error processing argument at index 0 */);
});
});
it('should throw an exception if invalid window', async () => {
// It is very unlikely that these window id exist.
const fakeSourceIds = ['window:99999999:0', 'window:123456:1',
@ -749,6 +752,7 @@ describe('BrowserWindow module', () => {
}).to.throw(/Invalid media source id/);
});
});
it('should not throw an exception', async () => {
const w2 = new BrowserWindow({ show: false, title: 'window2' });
const w2Shown = emittedOnce(w2, 'show');
@ -777,9 +781,11 @@ describe('BrowserWindow module', () => {
describe('sizing', () => {
let w = null as unknown as BrowserWindow;
beforeEach(() => {
w = new BrowserWindow({ show: false, width: 400, height: 400 });
});
afterEach(async () => {
await closeWindow(w);
w = null as unknown as BrowserWindow;
@ -4187,7 +4193,6 @@ describe('BrowserWindow module', () => {
});
});
const features = process.electronBinding('features');
ifdescribe(features.isOffscreenRenderingEnabled())('offscreen rendering', () => {
let w: BrowserWindow;
beforeEach(function () {

View file

@ -128,7 +128,7 @@ describe('node feature', () => {
let child: childProcess.ChildProcessWithoutNullStreams;
let exitPromise: Promise<any[]>;
it('Prohibits crypto-related flags in ELECTRON_RUN_AS_NODE mode', (done) => {
ifit(features.isRunAsNodeEnabled())('Prohibits crypto-related flags in ELECTRON_RUN_AS_NODE mode', (done) => {
after(async () => {
const [code, signal] = await exitPromise;
expect(signal).to.equal(null);

View file

@ -1009,13 +1009,7 @@ describe('<webview> tag', function () {
});
});
describe('<webview>.printToPDF()', () => {
before(() => {
if (!features.isPrintingEnabled()) {
this.skip();
}
});
ifdescribe(features.isPrintingEnabled())('<webview>.printToPDF()', () => {
it('rejects on incorrectly typed parameters', async () => {
const badTypes = {
marginsType: 'terrible',