mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-24 10:27:10 +02:00
All: Fix calls to non-existent function (#2675)
* Fix calls to non-existent function * Add tests. * Fix travis lint problems.
This commit is contained in:
parent
9b562276f3
commit
63a2f7b7a5
@ -93,10 +93,10 @@ describe('integration_ShowAllNotes', function() {
|
||||
|
||||
it('should support note duplication', asyncTest(async () => {
|
||||
// setup
|
||||
let folder1 = await Folder.save({ title: 'folder1' });
|
||||
let folder2 = await Folder.save({ title: 'folder2' });
|
||||
let note1 = await Note.save({ title: 'note1', parent_id: folder1.id });
|
||||
let note2 = await Note.save({ title: 'note2', parent_id: folder2.id });
|
||||
const folder1 = await Folder.save({ title: 'folder1' });
|
||||
const folder2 = await Folder.save({ title: 'folder2' });
|
||||
const note1 = await Note.save({ title: 'note1', parent_id: folder1.id });
|
||||
const note2 = await Note.save({ title: 'note2', parent_id: folder2.id });
|
||||
testApp.dispatch({ type: 'FOLDER_SELECT', id: folder1.id }); // active folder
|
||||
await time.msleep(100);
|
||||
testApp.dispatch({ type: 'NOTE_SELECT', id: note1.id });
|
||||
@ -130,10 +130,10 @@ describe('integration_ShowAllNotes', function() {
|
||||
|
||||
it('should support changing the note parent', asyncTest(async () => {
|
||||
// setup
|
||||
let folder1 = await Folder.save({ title: 'folder1' });
|
||||
let folder2 = await Folder.save({ title: 'folder2' });
|
||||
let note1 = await Note.save({ title: 'note1', parent_id: folder1.id });
|
||||
let note2 = await Note.save({ title: 'note1', parent_id: folder2.id });
|
||||
const folder1 = await Folder.save({ title: 'folder1' });
|
||||
const folder2 = await Folder.save({ title: 'folder2' });
|
||||
const note1 = await Note.save({ title: 'note1', parent_id: folder1.id });
|
||||
const note2 = await Note.save({ title: 'note1', parent_id: folder2.id });
|
||||
testApp.dispatch({ type: 'FOLDER_SELECT', id: folder1.id }); // active folder
|
||||
await time.msleep(100);
|
||||
testApp.dispatch({ type: 'NOTE_SELECT', id: note1.id });
|
||||
|
@ -58,11 +58,11 @@ describe('models_BaseItem', function() {
|
||||
}));
|
||||
|
||||
it('should correctly unserialize note timestamps', asyncTest(async () => {
|
||||
let folder = await Folder.save({ title: 'folder' });
|
||||
let note = await Note.save({ title: 'note', parent_id: folder.id });
|
||||
const folder = await Folder.save({ title: 'folder' });
|
||||
const note = await Note.save({ title: 'note', parent_id: folder.id });
|
||||
|
||||
let serialized = await Note.serialize(note);
|
||||
let unserialized = await Note.unserialize(serialized);
|
||||
const serialized = await Note.serialize(note);
|
||||
const unserialized = await Note.unserialize(serialized);
|
||||
|
||||
expect(unserialized.created_time).toEqual(note.created_time);
|
||||
expect(unserialized.updated_time).toEqual(note.updated_time);
|
||||
|
@ -195,4 +195,25 @@ describe('models_Note', function() {
|
||||
|
||||
expect(sortedIds(afterDelete)).toEqual(sortedIds(beforeDelete));
|
||||
}));
|
||||
|
||||
it('should not move to conflict folder', asyncTest(async () => {
|
||||
const folder1 = await Folder.save({ title: 'Folder' });
|
||||
const folder2 = await Folder.save({ title: Folder.conflictFolderTitle(), id: Folder.conflictFolderId() });
|
||||
const note1 = await Note.save({ title: 'note', parent_id: folder1.id });
|
||||
|
||||
const hasThrown = await checkThrowAsync(async () => await Folder.moveToFolder(note1.id, folder2.id));
|
||||
expect(hasThrown).toBe(true);
|
||||
|
||||
const note = await Note.load(note1.id);
|
||||
expect(note.parent_id).toEqual(folder1.id);
|
||||
}));
|
||||
|
||||
it('should not copy to conflict folder', asyncTest(async () => {
|
||||
const folder1 = await Folder.save({ title: 'Folder' });
|
||||
const folder2 = await Folder.save({ title: Folder.conflictFolderTitle(), id: Folder.conflictFolderId() });
|
||||
const note1 = await Note.save({ title: 'note', parent_id: folder1.id });
|
||||
|
||||
const hasThrown = await checkThrowAsync(async () => await Folder.copyToFolder(note1.id, folder2.id));
|
||||
expect(hasThrown).toBe(true);
|
||||
}));
|
||||
});
|
||||
|
@ -448,7 +448,7 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static async copyToFolder(noteId, folderId) {
|
||||
if (folderId == this.getClass('Folder').conflictFolderId()) throw new Error(_('Cannot copy note to "%s" notebook', this.getClass('Folder').conflictFolderIdTitle()));
|
||||
if (folderId == this.getClass('Folder').conflictFolderId()) throw new Error(_('Cannot copy note to "%s" notebook', this.getClass('Folder').conflictFolderTitle()));
|
||||
|
||||
return Note.duplicate(noteId, {
|
||||
changes: {
|
||||
@ -459,7 +459,7 @@ class Note extends BaseItem {
|
||||
}
|
||||
|
||||
static async moveToFolder(noteId, folderId) {
|
||||
if (folderId == this.getClass('Folder').conflictFolderId()) throw new Error(_('Cannot move note to "%s" notebook', this.getClass('Folder').conflictFolderIdTitle()));
|
||||
if (folderId == this.getClass('Folder').conflictFolderId()) throw new Error(_('Cannot move note to "%s" notebook', this.getClass('Folder').conflictFolderTitle()));
|
||||
|
||||
// When moving a note to a different folder, the user timestamp is not updated.
|
||||
// However updated_time is updated so that the note can be synced later on.
|
||||
|
Loading…
Reference in New Issue
Block a user