Skip to content

Commit

Permalink
SDA-3833 (Update isDevEnv check) (finos#2070)
Browse files Browse the repository at this point in the history
* SDA-3833 - Update isDevEnv check

* SDA-3833 - Update isDevEnv for unit tests
  • Loading branch information
KiranNiranjan authored Jan 11, 2024
1 parent d5647f0 commit b862bd5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .run/Demo (Build & Run).run.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Demo (Build &amp; Run)" type="NodeJSConfigurationType" application-parameters=". --url=file://$PROJECT_DIR$/src/demo/index.html" path-to-node="$PROJECT_DIR$/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron" working-dir="$PROJECT_DIR$">
<envs>
<env name="ELECTRON_DEV" value="true" />
<env name="ELECTRON_FORCE_IS_PACKAGED" value="true" />
<env name="ELECTRON_DEBUGGING" value="true" />
</envs>
<method v="2">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"postinstall": "electron-builder install-app-deps",
"start": "run-s compile browserify && cross-env ELECTRON_DEV=true electron .",
"test": "run-s lint test:unit",
"test:unit": "cross-env ELECTRON_QA=true jest --config jest-config.json --runInBand --detectOpenHandles",
"test:unit": "cross-env ELECTRON_FORCE_IS_PACKAGED=false ELECTRON_QA=true jest --config jest-config.json --runInBand --detectOpenHandles",
"unpacked-mac": "npm run prebuild && npm run test && ./node_modules/.bin/electron-builder build --mac",
"unpacked-win": "npm run prebuild && npm run test && node_modules\\.bin\\electron-builder build --win --x64"
},
Expand Down
18 changes: 18 additions & 0 deletions spec/config.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,24 @@ jest.mock('electron-log');
jest.mock('../src/app/auto-update-handler', () => {
return {};
});
jest.mock('../src/common/env', () => {
return {
isWindowsOS: true,
isLinux: false,
isMac: false,
isDevEnv: true,
};
});

jest.mock('../src/common/logger', () => {
return {
logger: {
setLoggerWindow: jest.fn(),
error: jest.fn(),
info: jest.fn(),
},
};
});

describe('config', () => {
const configFileName: string = 'Symphony.config';
Expand Down
5 changes: 2 additions & 3 deletions src/common/env.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export const isDevEnv = process.env.ELECTRON_DEV
? process.env.ELECTRON_DEV.trim().toLowerCase() === 'true'
: false;
import { app } from 'electron';
export const isDevEnv = !app?.isPackaged;
export const isElectronQA = !!process.env.ELECTRON_QA;

export const isMac = process.platform === 'darwin';
Expand Down

0 comments on commit b862bd5

Please sign in to comment.