mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-11 11:06:16 -08:00
fix(electron): create window when app is already ready
This commit is contained in:
1 parent
916e7608f3
commit
1a302a9c33
2 files changed
+23
-1
No files matched your search
@@ -4,6 +4,8 @@ jest.mock('electron', () => ({
|
||||
app: {
|
||||
getPath: jest.fn(() => '/tmp'),
|
||||
isPackaged: false,
|
||||
isReady: jest.fn(() => false),
|
||||
on: jest.fn(),
|
||||
},
|
||||
BrowserWindow: jest.fn(),
|
||||
Menu: {
|
||||
@@ -230,6 +232,22 @@ describe('Electron app security helpers', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('creates the main window immediately when Electron is already ready', () => {
|
||||
const mainWindow = createMockMainWindow();
|
||||
(BrowserWindow as unknown as jest.Mock).mockReturnValue(mainWindow);
|
||||
(electronApp.isReady as jest.Mock).mockReturnValue(true);
|
||||
|
||||
App.main(electronApp, BrowserWindow);
|
||||
|
||||
expect(BrowserWindow).toHaveBeenCalled();
|
||||
expect(electronApp.on).not.toHaveBeenCalledWith(
|
||||
'ready',
|
||||
expect.any(Function)
|
||||
);
|
||||
expect(mainWindow.loadURL).not.toHaveBeenCalled();
|
||||
expect(mainWindow.loadFile).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('clears only service worker registrations and cache storage', async () => {
|
||||
await clearElectronServiceWorkerStorage();
|
||||
|
||||
|
||||
@@ -476,7 +476,11 @@ export default class App {
|
||||
App.application = app;
|
||||
|
||||
App.application.on('window-all-closed', App.onWindowAllClosed); // Quit when all windows are closed.
|
||||
App.application.on('ready', App.onReady); // App is ready to load data
|
||||
if (App.application.isReady()) {
|
||||
App.onReady();
|
||||
} else {
|
||||
App.application.on('ready', App.onReady); // App is ready to load data
|
||||
}
|
||||
App.application.on('activate', App.onActivate); // App is activated
|
||||
App.application.on('before-quit', () => {
|
||||
if (App.mainWindow)
|
||||
|
||||
Reference in new issue
Block a user