
* Upgrade to ESLint v8 * Upgrade TypeScript, api-types, react-intl * Remove unnecessary dependencies * Update to React 17.0.2 * npm audit fixes, remove storybook * Lock some packages * Remove nan patch * Remove some deprecated dependencies * Fix lint/type/tests * Merge'd * Fix bad use of spawn * Fix notarize * Fix afterpack, switch to tsc es2020 * Fix api types * Use @mattermost/eslint-plugin
36 lines
965 B
JavaScript
36 lines
965 B
JavaScript
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
import fs from 'fs';
|
|
|
|
import * as Validator from 'common/Validator';
|
|
|
|
import {AppVersionManager} from './AppVersionManager';
|
|
|
|
jest.mock('electron', () => ({
|
|
ipcMain: {
|
|
on: jest.fn(),
|
|
},
|
|
}));
|
|
|
|
jest.mock('fs', () => ({
|
|
readFileSync: jest.fn(),
|
|
writeFile: jest.fn(),
|
|
}));
|
|
|
|
jest.mock('common/Validator', () => ({
|
|
validateAppState: jest.fn(),
|
|
}));
|
|
|
|
describe('main/AppVersionManager', () => {
|
|
it('should wipe out JSON file when validation fails', () => {
|
|
fs.readFileSync.mockReturnValue('some bad JSON');
|
|
Validator.validateAppState.mockReturnValue(false);
|
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
const appVersionManager = new AppVersionManager('somefilename.txt');
|
|
|
|
expect(fs.writeFile).toBeCalledWith('somefilename.txt', '{}', expect.any(Function));
|
|
});
|
|
});
|