test: fix app.dock
for corrected type (#46110)
test: fix app.dock for corrected type
This commit is contained in:
parent
71f3ff6bf2
commit
dcbab692c0
3 changed files with 28 additions and 27 deletions
|
@ -1668,19 +1668,19 @@ describe('app module', () => {
|
||||||
|
|
||||||
ifdescribe(process.platform === 'darwin')('dock APIs', () => {
|
ifdescribe(process.platform === 'darwin')('dock APIs', () => {
|
||||||
after(async () => {
|
after(async () => {
|
||||||
await app.dock.show();
|
await app.dock?.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('dock.setMenu', () => {
|
describe('dock.setMenu', () => {
|
||||||
it('can be retrieved via dock.getMenu', () => {
|
it('can be retrieved via dock.getMenu', () => {
|
||||||
expect(app.dock.getMenu()).to.equal(null);
|
expect(app.dock?.getMenu()).to.equal(null);
|
||||||
const menu = new Menu();
|
const menu = new Menu();
|
||||||
app.dock.setMenu(menu);
|
app.dock?.setMenu(menu);
|
||||||
expect(app.dock.getMenu()).to.equal(menu);
|
expect(app.dock?.getMenu()).to.equal(menu);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('keeps references to the menu', () => {
|
it('keeps references to the menu', () => {
|
||||||
app.dock.setMenu(new Menu());
|
app.dock?.setMenu(new Menu());
|
||||||
const v8Util = process._linkedBinding('electron_common_v8_util');
|
const v8Util = process._linkedBinding('electron_common_v8_util');
|
||||||
v8Util.requestGarbageCollectionForTesting();
|
v8Util.requestGarbageCollectionForTesting();
|
||||||
});
|
});
|
||||||
|
@ -1690,56 +1690,56 @@ describe('app module', () => {
|
||||||
it('throws a descriptive error for a bad icon path', () => {
|
it('throws a descriptive error for a bad icon path', () => {
|
||||||
const badPath = path.resolve('I', 'Do', 'Not', 'Exist');
|
const badPath = path.resolve('I', 'Do', 'Not', 'Exist');
|
||||||
expect(() => {
|
expect(() => {
|
||||||
app.dock.setIcon(badPath);
|
app.dock?.setIcon(badPath);
|
||||||
}).to.throw(/Failed to load image from path (.+)/);
|
}).to.throw(/Failed to load image from path (.+)/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('dock.bounce', () => {
|
describe('dock.bounce', () => {
|
||||||
it('should return -1 for unknown bounce type', () => {
|
it('should return -1 for unknown bounce type', () => {
|
||||||
expect(app.dock.bounce('bad type' as any)).to.equal(-1);
|
expect(app.dock?.bounce('bad type' as any)).to.equal(-1);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a positive number for informational type', () => {
|
it('should return a positive number for informational type', () => {
|
||||||
const appHasFocus = !!BrowserWindow.getFocusedWindow();
|
const appHasFocus = !!BrowserWindow.getFocusedWindow();
|
||||||
if (!appHasFocus) {
|
if (!appHasFocus) {
|
||||||
expect(app.dock.bounce('informational')).to.be.at.least(0);
|
expect(app.dock?.bounce('informational')).to.be.at.least(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should return a positive number for critical type', () => {
|
it('should return a positive number for critical type', () => {
|
||||||
const appHasFocus = !!BrowserWindow.getFocusedWindow();
|
const appHasFocus = !!BrowserWindow.getFocusedWindow();
|
||||||
if (!appHasFocus) {
|
if (!appHasFocus) {
|
||||||
expect(app.dock.bounce('critical')).to.be.at.least(0);
|
expect(app.dock?.bounce('critical')).to.be.at.least(0);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('dock.cancelBounce', () => {
|
describe('dock.cancelBounce', () => {
|
||||||
it('should not throw', () => {
|
it('should not throw', () => {
|
||||||
app.dock.cancelBounce(app.dock.bounce('critical'));
|
app.dock?.cancelBounce(app.dock?.bounce('critical'));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('dock.setBadge', () => {
|
describe('dock.setBadge', () => {
|
||||||
after(() => {
|
after(() => {
|
||||||
app.dock.setBadge('');
|
app.dock?.setBadge('');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should not throw', () => {
|
it('should not throw', () => {
|
||||||
app.dock.setBadge('1');
|
app.dock?.setBadge('1');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should be retrievable via getBadge', () => {
|
it('should be retrievable via getBadge', () => {
|
||||||
app.dock.setBadge('test');
|
app.dock?.setBadge('test');
|
||||||
expect(app.dock.getBadge()).to.equal('test');
|
expect(app.dock?.getBadge()).to.equal('test');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('dock.hide', () => {
|
describe('dock.hide', () => {
|
||||||
it('should not throw', () => {
|
it('should not throw', () => {
|
||||||
app.dock.hide();
|
app.dock?.hide();
|
||||||
expect(app.dock.isVisible()).to.equal(false);
|
expect(app.dock?.isVisible()).to.equal(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1748,17 +1748,17 @@ describe('app module', () => {
|
||||||
// See https://github.com/electron/electron/pull/25269 for more.
|
// See https://github.com/electron/electron/pull/25269 for more.
|
||||||
describe('dock.show', () => {
|
describe('dock.show', () => {
|
||||||
it('should not throw', () => {
|
it('should not throw', () => {
|
||||||
return app.dock.show().then(() => {
|
return app.dock?.show().then(() => {
|
||||||
expect(app.dock.isVisible()).to.equal(true);
|
expect(app.dock?.isVisible()).to.equal(true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('returns a Promise', () => {
|
it('returns a Promise', () => {
|
||||||
expect(app.dock.show()).to.be.a('promise');
|
expect(app.dock?.show()).to.be.a('promise');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('eventually fulfills', async () => {
|
it('eventually fulfills', async () => {
|
||||||
await expect(app.dock.show()).to.eventually.be.fulfilled.equal(undefined);
|
await expect(app.dock?.show()).to.eventually.be.fulfilled.equal(undefined);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2499,12 +2499,12 @@ describe('BrowserWindow module', () => {
|
||||||
it('sets the progress', () => {
|
it('sets the progress', () => {
|
||||||
expect(() => {
|
expect(() => {
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
app.dock.setIcon(path.join(fixtures, 'assets', 'logo.png'));
|
app.dock?.setIcon(path.join(fixtures, 'assets', 'logo.png'));
|
||||||
}
|
}
|
||||||
w.setProgressBar(0.5);
|
w.setProgressBar(0.5);
|
||||||
|
|
||||||
if (process.platform === 'darwin') {
|
if (process.platform === 'darwin') {
|
||||||
app.dock.setIcon(null as any);
|
app.dock?.setIcon(null as any);
|
||||||
}
|
}
|
||||||
w.setProgressBar(-1);
|
w.setProgressBar(-1);
|
||||||
}).to.not.throw();
|
}).to.not.throw();
|
||||||
|
|
|
@ -230,11 +230,12 @@ const dockMenu = Menu.buildFromTemplate([
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
app.dock.setMenu(dockMenu);
|
|
||||||
app.dock.setBadge('foo');
|
app.dock?.setMenu(dockMenu);
|
||||||
const dockid = app.dock.bounce('informational');
|
app.dock?.setBadge('foo');
|
||||||
app.dock.cancelBounce(dockid);
|
const dockid = app.dock?.bounce('informational');
|
||||||
app.dock.setIcon('/path/to/icon.png');
|
app.dock?.cancelBounce(dockid);
|
||||||
|
app.dock?.setIcon('/path/to/icon.png');
|
||||||
|
|
||||||
app.setBadgeCount(app.getBadgeCount() + 1);
|
app.setBadgeCount(app.getBadgeCount() + 1);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue