Skip to content

Commit

Permalink
Improving tests
Browse files Browse the repository at this point in the history
  • Loading branch information
araujoarthur0 committed Feb 21, 2025
1 parent 0b609c6 commit 239ed1c
Showing 1 changed file with 29 additions and 15 deletions.
44 changes: 29 additions & 15 deletions __tests__/__main__/main-window.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -443,22 +443,36 @@ describe('main-window.mjs', () =>
});
});

it('Toggling wait state for the window', async() =>
describe('toggleMainWindowWait()', () =>
{
createWindow();
const mainWindow = getMainWindow();
let hasClass = await mainWindow.webContents.executeJavaScript('$("html").hasClass("wait")');
assert.strictEqual(hasClass, false, 'Starts without wait class');

toggleMainWindowWait(true);
await new Promise(r => setTimeout(r, 50));
hasClass = await mainWindow.webContents.executeJavaScript('$("html").hasClass("wait")');
assert.strictEqual(hasClass, true, 'Now has wait class');

toggleMainWindowWait(false);
await new Promise(r => setTimeout(r, 50));
hasClass = await mainWindow.webContents.executeJavaScript('$("html").hasClass("wait")');
assert.strictEqual(hasClass, false, 'Back to not having wait class');
it('Starts without wait class', () =>
{
createWindow();
const mainWindow = getMainWindow();
mainWindow.webContents.ipc.on(IpcConstants.WindowReadyToShow, async() =>
{
const hasClass = await mainWindow.webContents.executeJavaScript('$("html").hasClass("wait")');
assert.strictEqual(hasClass, false, 'Starts without wait class');
});
});

it('Toggling wait state for the window', () =>
{
createWindow();
const mainWindow = getMainWindow();
mainWindow.webContents.ipc.on(IpcConstants.WindowReadyToShow, async() =>
{
toggleMainWindowWait(true);
await new Promise(r => setTimeout(r, 50));
let hasClass = await mainWindow.webContents.executeJavaScript('$("html").hasClass("wait")');
assert.strictEqual(hasClass, true, 'Now has wait class');

toggleMainWindowWait(false);
await new Promise(r => setTimeout(r, 50));
hasClass = await mainWindow.webContents.executeJavaScript('$("html").hasClass("wait")');
assert.strictEqual(hasClass, false, 'Back to not having wait class');
});
});
});

afterEach(() =>
Expand Down

0 comments on commit 239ed1c

Please sign in to comment.