mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-02 13:39:27 -06:00
a053faedda
* ELECTRON-748 - Change title-bar from className to id Fix linter issues * ELECTRON-748 - Fix unit tests cases
46 lines
1.4 KiB
TypeScript
46 lines
1.4 KiB
TypeScript
import * as fs from 'fs';
|
|
import * as path from 'path';
|
|
import { cleanUpAppCache, createAppCacheFile } from '../src/app/app-cache-handler';
|
|
import { app, session } from './__mocks__/electron';
|
|
|
|
jest.mock('fs', () => ({
|
|
writeFileSync: jest.fn(),
|
|
existsSync: jest.fn(() => true),
|
|
unlinkSync: jest.fn(),
|
|
}));
|
|
|
|
jest.mock('../src/common/logger', () => {
|
|
return {
|
|
logger: {
|
|
error: jest.fn(),
|
|
info: jest.fn(),
|
|
},
|
|
};
|
|
});
|
|
|
|
describe('app cache handler', () => {
|
|
const cachePathExpected = path.join(app.getPath('userData'), 'CacheCheck');
|
|
|
|
it('should call `cleanUpAppCache` correctly', () => {
|
|
const spyFn = 'unlinkSync';
|
|
const spy = jest.spyOn(fs, spyFn);
|
|
cleanUpAppCache();
|
|
expect(spy).toBeCalledWith(cachePathExpected);
|
|
});
|
|
|
|
it('should call `clearCache` when `session.defaultSession` is not null', () => {
|
|
jest.spyOn(fs, 'existsSync').mockImplementation(() => false);
|
|
const spyFn = 'clearCache';
|
|
const spy = jest.spyOn(session.defaultSession, spyFn);
|
|
cleanUpAppCache();
|
|
expect(spy).lastCalledWith(expect.any(Function));
|
|
});
|
|
|
|
it('should call `createAppCacheFile` correctly', () => {
|
|
const spyFn = 'writeFileSync';
|
|
const spy = jest.spyOn(fs, spyFn);
|
|
createAppCacheFile();
|
|
expect(spy).lastCalledWith(cachePathExpected, '');
|
|
});
|
|
});
|