文件
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

39 行
1.5 KiB
TypeScript

import { runtime } from './newNote';
import { setupDatabaseAndSynchronizer, switchClient } from '@joplin/lib/testing/test-utils';
import Note from '@joplin/lib/models/Note';
import Folder from '@joplin/lib/models/Folder';
import Setting from '@joplin/lib/models/Setting';
describe('newNote', () => {
beforeEach(async () => {
await setupDatabaseAndSynchronizer(1);
await switchClient(1);
});
test.each([
[null, null],
['order', true],
['order', false],
])('should create a new note', async (sortOrderField: string, sortOrderReverse: boolean) => {
// The command needs an active folder ID.
const activeFolder = await Folder.save({ title: 'folder' });
const initialNote = await Note.save({ title: 'test', parent_id: activeFolder.id });
Setting.setValue('activeFolderId', activeFolder.id);
Setting.setValue('notes.sortOrder.field', sortOrderField);
Setting.setValue('notes.sortOrder.reverse', sortOrderReverse);
await runtime().execute(null, 'test note', true);
// Correct note should have been created
const newNote = (await Note.loadByField('body', 'test note'));
expect(newNote.body).toEqual('test note');
expect(newNote.parent_id).toEqual(activeFolder.id);
if (sortOrderField === 'order' && !!sortOrderReverse) {
expect(newNote.order).toBeGreaterThanOrEqual(initialNote.order + Note.defaultIntevalBetweenNotes);
} else if (sortOrderField === 'order' && !sortOrderReverse) {
expect(newNote.order).toBeLessThanOrEqual(initialNote.order - Note.defaultIntevalBetweenNotes);
} else {
expect(newNote.order).toEqual(0);
}
});
});