Skip to content

Commit

Permalink
♻️ App Menu instantiation method renamed to newAppMenu
Browse files Browse the repository at this point in the history
Signed-off-by: Marc Nuri <[email protected]>
  • Loading branch information
manusa committed Nov 5, 2022
1 parent 0ad1c68 commit f3cd6f7
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
8 changes: 6 additions & 2 deletions src/app-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ const webPreferences = {
preload: path.resolve(__dirname, '..', '..', 'bundles', 'app-menu.preload.js')
};

const initAppMenu = () => {
/**
* Creates a new BrowserView instance with the App Menu
* @returns {Electron.CrossProcessExports.BrowserView}
*/
const newAppMenu = () => {
const appMenu = new BrowserView({webPreferences});
appMenu.isAppMenu = true;
appMenu.setAutoResize({width: false, horizontal: false, height: false, vertical: false});
Expand All @@ -34,4 +38,4 @@ const initAppMenu = () => {

const isNotAppMenu = bv => bv.isAppMenu !== true;

module.exports = {initAppMenu, isNotAppMenu};
module.exports = {newAppMenu, isNotAppMenu};
8 changes: 4 additions & 4 deletions src/main/__tests__/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ describe('Main module test suite', () => {
nativeTheme: mockNativeTheme
}));
appMenuModule = require('../../app-menu');
jest.spyOn(appMenuModule, 'initAppMenu');
jest.spyOn(appMenuModule, 'newAppMenu');
settingsModule = require('../../settings');
jest.spyOn(settingsModule, 'loadSettings').mockImplementation(() => mockSettings);
jest.spyOn(settingsModule, 'updateSettings').mockImplementation();
Expand Down Expand Up @@ -179,7 +179,7 @@ describe('Main module test suite', () => {
mockAppMenu = {
setBounds: jest.fn()
};
jest.spyOn(appMenuModule, 'initAppMenu').mockImplementation(() => mockAppMenu);
jest.spyOn(appMenuModule, 'newAppMenu').mockImplementation(() => mockAppMenu);
main.init();
});
test('should set app-menu bounds', () => {
Expand Down Expand Up @@ -498,7 +498,7 @@ describe('Main module test suite', () => {
test('appMenuOpen, should show and resize app-menu', () => {
// Given
const mockAppMenu = {setBounds: jest.fn()};
jest.spyOn(appMenuModule, 'initAppMenu').mockImplementation(() => mockAppMenu);
jest.spyOn(appMenuModule, 'newAppMenu').mockImplementation(() => mockAppMenu);
main.init();
// When
mockIpc.listeners.appMenuOpen();
Expand All @@ -510,7 +510,7 @@ describe('Main module test suite', () => {
test('appMenuClose, should hide app-menu', () => {
// Given
const mockAppMenu = {isTheMockAppMenu: true};
jest.spyOn(appMenuModule, 'initAppMenu').mockImplementation(() => mockAppMenu);
jest.spyOn(appMenuModule, 'newAppMenu').mockImplementation(() => mockAppMenu);
main.init();
// When
mockIpc.listeners.appMenuClose();
Expand Down
4 changes: 2 additions & 2 deletions src/main/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
const {BrowserWindow, Notification, app, desktopCapturer, ipcMain: ipc, nativeTheme} = require('electron');
const {APP_EVENTS} = require('../constants');
const {initAppMenu, isNotAppMenu} = require('../app-menu');
const {newAppMenu, isNotAppMenu} = require('../app-menu');
const {TABS_CONTAINER_HEIGHT, initTabContainer, isNotTabContainer} = require('../chrome-tabs');
const {openHelpDialog} = require('../help');
const {loadSettings, updateSettings, openSettingsDialog} = require('../settings');
Expand Down Expand Up @@ -201,7 +201,7 @@ const initGlobalListeners = () => {
const browserVersionsReady = () => {
app.userAgentFallback = userAgentForView(mainWindow);
tabContainer = initTabContainer();
appMenu = initAppMenu();
appMenu = newAppMenu();
};

const init = () => {
Expand Down

0 comments on commit f3cd6f7

Please sign in to comment.