signal-desktop/ts/test-node/util/toggleMaximizedBrowserWindow_test.ts

38 lines
1.2 KiB
TypeScript
Raw Normal View History

2021-02-01 20:01:25 +00:00
// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as sinon from 'sinon';
import type { BrowserWindow } from 'electron';
2021-02-01 20:01:25 +00:00
import { toggleMaximizedBrowserWindow } from '../../util/toggleMaximizedBrowserWindow';
describe('toggleMaximizedBrowserWindow', () => {
const createFakeWindow = () => ({
isMaximized: sinon.stub(),
unmaximize: sinon.spy(),
maximize: sinon.spy(),
});
it('maximizes an unmaximized window', () => {
const browserWindow = createFakeWindow();
browserWindow.isMaximized.returns(false);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toggleMaximizedBrowserWindow((browserWindow as any) as BrowserWindow);
sinon.assert.calledOnce(browserWindow.maximize);
sinon.assert.notCalled(browserWindow.unmaximize);
});
it('unmaximizes a maximized window', () => {
const browserWindow = createFakeWindow();
browserWindow.isMaximized.returns(true);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
toggleMaximizedBrowserWindow((browserWindow as any) as BrowserWindow);
sinon.assert.notCalled(browserWindow.maximize);
sinon.assert.calledOnce(browserWindow.unmaximize);
});
});