From c39b05f92aa7fc75f6df4f426ce2bc9b7bde1c39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Andr=C3=A9s=20V=C3=A9lez=20Vidal?= Date: Tue, 8 Oct 2024 15:38:37 +0200 Subject: [PATCH] fix unit tests --- src/app/serverViewState.test.js | 3 +++ src/common/config/index.test.js | 6 ++++++ src/common/config/upgradePreferences.test.js | 6 ++++++ src/main/downloadsManager.test.js | 1 + src/main/tray/tray.test.js | 1 + src/main/views/MattermostBrowserView.test.js | 1 + src/main/views/downloadsDropdownMenuView.test.js | 1 + src/main/views/downloadsDropdownView.test.js | 1 + src/main/views/serverDropdownView.test.js | 3 +++ src/main/views/viewManager.test.js | 1 + 10 files changed, 24 insertions(+) diff --git a/src/app/serverViewState.test.js b/src/app/serverViewState.test.js index d0fb4299626..85d9a233291 100644 --- a/src/app/serverViewState.test.js +++ b/src/app/serverViewState.test.js @@ -15,6 +15,9 @@ import MainWindow from 'main/windows/mainWindow'; import {ServerViewState} from './serverViewState'; jest.mock('electron', () => ({ + app: { + getPath: jest.fn(() => '/valid/downloads/path'), + }, ipcMain: { on: jest.fn(), handle: jest.fn(), diff --git a/src/common/config/index.test.js b/src/common/config/index.test.js index 8caaaf508c3..72f88af1e59 100644 --- a/src/common/config/index.test.js +++ b/src/common/config/index.test.js @@ -94,6 +94,12 @@ jest.mock('common/config/RegistryConfig', () => { return jest.fn(); }); +jest.mock('electron', () => ({ + app: { + getPath: jest.fn(() => '/valid/downloads/path'), + }, +})); + describe('common/config', () => { it('should load buildConfig', () => { const config = new Config(); diff --git a/src/common/config/upgradePreferences.test.js b/src/common/config/upgradePreferences.test.js index 446afc456e6..9e9f1804eca 100644 --- a/src/common/config/upgradePreferences.test.js +++ b/src/common/config/upgradePreferences.test.js @@ -18,6 +18,12 @@ jest.mock('common/views/View', () => ({ }), })); +jest.mock('electron', () => ({ + app: { + getPath: jest.fn(() => '/valid/downloads/path'), + }, +})); + describe('common/config/upgradePreferences', () => { describe('upgradeV0toV1', () => { it('should upgrade from v0', () => { diff --git a/src/main/downloadsManager.test.js b/src/main/downloadsManager.test.js index fc16e4e87ba..8b9cfe1acd4 100644 --- a/src/main/downloadsManager.test.js +++ b/src/main/downloadsManager.test.js @@ -28,6 +28,7 @@ jest.mock('electron', () => { return { app: { getAppPath: jest.fn(), + getPath: jest.fn(() => '/valid/downloads/path'), }, BrowserView: jest.fn().mockImplementation(() => ({ webContents: { diff --git a/src/main/tray/tray.test.js b/src/main/tray/tray.test.js index 2dac7fc29ae..eb39a5f9ac4 100644 --- a/src/main/tray/tray.test.js +++ b/src/main/tray/tray.test.js @@ -30,6 +30,7 @@ jest.mock('electron', () => { getAppPath: () => '/path/to/app', isReady: jest.fn(), setPath: jest.fn(), + getPath: jest.fn(() => '/valid/downloads/path'), }, ipcMain: { emit: jest.fn(), diff --git a/src/main/views/MattermostBrowserView.test.js b/src/main/views/MattermostBrowserView.test.js index bb300b8c13b..033f1b4e920 100644 --- a/src/main/views/MattermostBrowserView.test.js +++ b/src/main/views/MattermostBrowserView.test.js @@ -17,6 +17,7 @@ import MainWindow from '../windows/mainWindow'; jest.mock('electron', () => ({ app: { getVersion: () => '5.0.0', + getPath: jest.fn(() => '/valid/downloads/path'), }, BrowserView: jest.fn().mockImplementation(() => ({ webContents: { diff --git a/src/main/views/downloadsDropdownMenuView.test.js b/src/main/views/downloadsDropdownMenuView.test.js index cec506f7664..c805d9668c5 100644 --- a/src/main/views/downloadsDropdownMenuView.test.js +++ b/src/main/views/downloadsDropdownMenuView.test.js @@ -28,6 +28,7 @@ jest.mock('electron', () => { return { app: { getAppPath: () => '', + getPath: jest.fn(() => '/valid/downloads/path'), }, BrowserView: jest.fn().mockImplementation(() => ({ webContents: { diff --git a/src/main/views/downloadsDropdownView.test.js b/src/main/views/downloadsDropdownView.test.js index a42788871d3..e5d76bff1f2 100644 --- a/src/main/views/downloadsDropdownView.test.js +++ b/src/main/views/downloadsDropdownView.test.js @@ -36,6 +36,7 @@ jest.mock('electron', () => { return { app: { getAppPath: () => '', + getPath: jest.fn(() => '/valid/downloads/path'), }, BrowserView: jest.fn().mockImplementation(() => ({ webContents: { diff --git a/src/main/views/serverDropdownView.test.js b/src/main/views/serverDropdownView.test.js index 91d88890306..a98e42ecc2c 100644 --- a/src/main/views/serverDropdownView.test.js +++ b/src/main/views/serverDropdownView.test.js @@ -25,6 +25,9 @@ jest.mock('electron', () => ({ ipcMain: { on: jest.fn(), }, + app: { + getPath: jest.fn(() => '/valid/downloads/path'), + }, })); jest.mock('main/windows/mainWindow', () => ({ on: jest.fn(), diff --git a/src/main/views/viewManager.test.js b/src/main/views/viewManager.test.js index 339ac8744bd..fe6f5170c27 100644 --- a/src/main/views/viewManager.test.js +++ b/src/main/views/viewManager.test.js @@ -18,6 +18,7 @@ import {ViewManager} from './viewManager'; jest.mock('electron', () => ({ app: { getAppPath: () => '/path/to/app', + getPath: jest.fn(() => '/valid/downloads/path'), }, dialog: { showErrorBox: jest.fn(),