一些检查失败了
automerge / automerge (push) Has been cancelled
react-native-android-build-apk / AssembleRelease (push) Has been cancelled
Build macOS M1 / Main (push) Has been cancelled
Joplin Continuous Integration / Main (macos-15-intel) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / Main (ubuntu-22.04-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-11-vs2026-arm) (push) Has been cancelled
Joplin Continuous Integration / Main (windows-2025) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04) (push) Has been cancelled
Joplin Continuous Integration / ServerDockerImage (ubuntu-22.04-arm) (push) Has been cancelled
Joplin UI tests / Main (ubuntu-22.04) (push) Has been cancelled
Joplin UI tests / Main (windows-2025) (push) Has been cancelled
Joplin UI tests / Mobile (push) Has been cancelled
Close stale issues / ProcessStaleIssues (push) Has been cancelled
45 行
1.3 KiB
TypeScript
45 行
1.3 KiB
TypeScript
|
|
let currentProfileDirectory: string;
|
|
|
|
jest.doMock('../bridge', () => () => ({
|
|
// Mock the bridge functions used by restartInSafeModeFromMain
|
|
// to remove the dependency on Electron.
|
|
restart: jest.fn(),
|
|
processArgv: () => [
|
|
// The argument parser expects the first two arguments to
|
|
// be the path to NodeJS and the second to be the main filename.
|
|
process.argv[0], __filename,
|
|
|
|
// Only the following arguments are used.
|
|
'--profile', currentProfileDirectory,
|
|
],
|
|
env: () => 'dev',
|
|
appName: () => 'joplin-desktop',
|
|
}));
|
|
|
|
import { mkdtemp, readFile, remove } from 'fs-extra';
|
|
import restartInSafeModeFromMain from './restartInSafeModeFromMain';
|
|
import { tmpdir } from 'os';
|
|
import { join } from 'path';
|
|
import { safeModeFlagFilename } from '@joplin/lib/BaseApplication';
|
|
|
|
|
|
describe('restartInSafeModeFromMain', () => {
|
|
beforeEach(async () => {
|
|
currentProfileDirectory = await mkdtemp(join(tmpdir(), 'safemode-restart-test'));
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await remove(currentProfileDirectory);
|
|
});
|
|
|
|
test('should create a safe mode flag file', async () => {
|
|
await restartInSafeModeFromMain();
|
|
const safeModeFlagFilepath = join(
|
|
currentProfileDirectory, safeModeFlagFilename,
|
|
);
|
|
expect(await readFile(safeModeFlagFilepath, 'utf8')).toBe('true');
|
|
});
|
|
});
|
|
|