
yargs, the command line parsing library, was unable to read the app's version automatically from package.json fix by passing the app's version as electron sees it
29 lines
1.0 KiB
JavaScript
29 lines
1.0 KiB
JavaScript
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
const dummyVersion = '1.2.3-test';
|
|
|
|
jest.mock('electron', () => ({
|
|
app: {
|
|
getVersion: () => dummyVersion,
|
|
},
|
|
}));
|
|
|
|
import parse from 'main/ParseArgs';
|
|
|
|
describe('main/ParseArgs', () => {
|
|
it('should remove arguments following a deeplink', () => {
|
|
const args = parse(['mattermost', '--disableDevMode', 'mattermost://server-1.com']);
|
|
expect(args.disableDevMode).toBe(true);
|
|
});
|
|
|
|
it('should show version and exit when specified', async () => {
|
|
jest.spyOn(process.stdout, 'write').mockImplementation(() => {});
|
|
const exitSpy = jest.spyOn(process, 'exit').mockImplementation(() => {});
|
|
const logSpy = jest.spyOn(console, 'log').mockImplementation(() => {});
|
|
parse(['mattermost', '--version', 'mattermost://server-1.com']);
|
|
expect(exitSpy).toHaveBeenCalledWith(0);
|
|
expect(logSpy).toHaveBeenCalledWith(dummyVersion);
|
|
});
|
|
});
|