forked from laurent22/joplin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Desktop: Fixes laurent22#10668: Tags and Delete note not being availa…
…ble on Search and on All Notes list (laurent22#10729)
- Loading branch information
Showing
4 changed files
with
78 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
74 changes: 74 additions & 0 deletions
74
packages/lib/services/commands/stateToWhenClauseContext.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { State } from '../../reducer'; | ||
import { getTrashFolderId } from '../trash'; | ||
import stateToWhenClauseContext from './stateToWhenClauseContext'; | ||
|
||
|
||
describe('stateToWhenClauseContext', () => { | ||
|
||
it('should be in trash if selected note has been deleted and selected folder is trash', async () => { | ||
const applicationState = { | ||
selectedNoteIds: ['1'], | ||
selectedFolderId: getTrashFolderId(), | ||
notes: [ | ||
{ id: '1', deleted_time: 1722567036580 }, | ||
], | ||
folders: [], | ||
} as State; | ||
const resultingState = stateToWhenClauseContext(applicationState); | ||
|
||
expect(resultingState.inTrash).toBe(true); | ||
}); | ||
|
||
it('should NOT be in trash if selected note has not been deleted', async () => { | ||
const applicationState = { | ||
selectedNoteIds: ['1'], | ||
selectedFolderId: getTrashFolderId(), | ||
notes: [ | ||
{ id: '1', deleted_time: 0 }, | ||
], | ||
folders: [], | ||
} as State; | ||
const resultingState = stateToWhenClauseContext(applicationState); | ||
|
||
expect(resultingState.inTrash).toBe(false); | ||
}); | ||
|
||
it('should NOT be in trash if selected folder is not trash', async () => { | ||
const applicationState = { | ||
selectedNoteIds: ['1'], | ||
selectedFolderId: 'any-other-folder', | ||
notes: [ | ||
{ id: '1', deleted_time: 1722567036580 }, | ||
], | ||
folders: [], | ||
} as State; | ||
const resultingState = stateToWhenClauseContext(applicationState); | ||
|
||
expect(resultingState.inTrash).toBe(false); | ||
}); | ||
|
||
it('should be in trash if command folder is deleted', async () => { | ||
const applicationState = { | ||
notes: [], | ||
folders: [ | ||
{ id: '1', deleted_time: 1722567036580, share_id: '', parent_id: '' }, | ||
], | ||
} as State; | ||
const resultingState = stateToWhenClauseContext(applicationState, { commandFolderId: '1' }); | ||
|
||
expect(resultingState.inTrash).toBe(true); | ||
}); | ||
|
||
it('should NOT be in trash if command folder is not deleted', async () => { | ||
const applicationState = { | ||
notes: [], | ||
folders: [ | ||
{ id: '1', deleted_time: 0, share_id: '', parent_id: '' }, | ||
], | ||
} as State; | ||
const resultingState = stateToWhenClauseContext(applicationState, { commandFolderId: '1' }); | ||
|
||
expect(resultingState.inTrash).toBe(false); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters