文件
chen 301194963b
一些检查失败了
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
feat: Initial clean release of CHM
2026-11-04 11:29:39 +08:00

52 行
1.8 KiB
TypeScript

import { shouldCancelPendingEnableAfterMasterPasswordDialog, shouldOpenMasterPasswordDialogForEnable, shouldResumeEnableAfterMasterPasswordDialog } from './enableFlow';
describe('enableFlow', () => {
test('opens the master password dialog when enabling encryption without a stored master password', () => {
expect(shouldOpenMasterPasswordDialogForEnable({
hasMasterPassword: false,
masterPasswordDialogOpen: false,
})).toBe(true);
});
test('does not reopen the master password dialog if it is already open', () => {
expect(shouldOpenMasterPasswordDialogForEnable({
hasMasterPassword: false,
masterPasswordDialogOpen: true,
})).toBe(false);
});
test('does not open the master password dialog when a master password already exists', () => {
expect(shouldOpenMasterPasswordDialogForEnable({
hasMasterPassword: true,
masterPasswordDialogOpen: false,
})).toBe(false);
});
test('resumes enabling encryption after the dialog closes with a saved password', () => {
expect(shouldResumeEnableAfterMasterPasswordDialog({
pendingEnableEncryption: true,
wasMasterPasswordDialogOpen: true,
masterPasswordDialogOpen: false,
masterPassword: 'new-password',
})).toBe(true);
});
test('cancels the pending enable flow if the dialog closes without a password', () => {
expect(shouldCancelPendingEnableAfterMasterPasswordDialog({
pendingEnableEncryption: true,
wasMasterPasswordDialogOpen: true,
masterPasswordDialogOpen: false,
masterPassword: '',
})).toBe(true);
});
test('does not resume while the dialog is still open', () => {
expect(shouldResumeEnableAfterMasterPasswordDialog({
pendingEnableEncryption: true,
wasMasterPasswordDialogOpen: true,
masterPasswordDialogOpen: true,
masterPassword: 'new-password',
})).toBe(false);
});
});