Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pvev committed Oct 8, 2024
1 parent a558975 commit c39b05f
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/app/serverViewState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
6 changes: 6 additions & 0 deletions src/common/config/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 6 additions & 0 deletions src/common/config/upgradePreferences.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down
1 change: 1 addition & 0 deletions src/main/downloadsManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jest.mock('electron', () => {
return {
app: {
getAppPath: jest.fn(),
getPath: jest.fn(() => '/valid/downloads/path'),
},
BrowserView: jest.fn().mockImplementation(() => ({
webContents: {
Expand Down
1 change: 1 addition & 0 deletions src/main/tray/tray.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/main/views/MattermostBrowserView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down
1 change: 1 addition & 0 deletions src/main/views/downloadsDropdownMenuView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jest.mock('electron', () => {
return {
app: {
getAppPath: () => '',
getPath: jest.fn(() => '/valid/downloads/path'),
},
BrowserView: jest.fn().mockImplementation(() => ({
webContents: {
Expand Down
1 change: 1 addition & 0 deletions src/main/views/downloadsDropdownView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jest.mock('electron', () => {
return {
app: {
getAppPath: () => '',
getPath: jest.fn(() => '/valid/downloads/path'),
},
BrowserView: jest.fn().mockImplementation(() => ({
webContents: {
Expand Down
3 changes: 3 additions & 0 deletions src/main/views/serverDropdownView.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
1 change: 1 addition & 0 deletions src/main/views/viewManager.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down

0 comments on commit c39b05f

Please sign in to comment.