Files
mattermostest/src/main/ParseArgs.test.js
vas 8dd7d3dcc5 fix version flags displaying bad version on linux (#1422) (#2089)
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
2022-05-10 15:52:33 -04:00

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);
});
});