You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-11-23 22:36:32 +02:00
Chore: Add test for joplinServerConnected condition (#13352)
This commit is contained in:
@@ -55,7 +55,7 @@ export default class SyncTargetRegistry {
|
||||
}
|
||||
|
||||
public static allIds() {
|
||||
return Object.keys(this.reg);
|
||||
return Object.keys(this.reg).map(key => Number(key));
|
||||
}
|
||||
|
||||
public static nameToId(name: string) {
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { State } from '../../reducer';
|
||||
import { defaultState, State } from '../../reducer';
|
||||
import SyncTargetRegistry from '../../SyncTargetRegistry';
|
||||
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'],
|
||||
@@ -82,4 +82,22 @@ describe('stateToWhenClauseContext', () => {
|
||||
expect(resultingState.inTrash).toBe(false);
|
||||
});
|
||||
|
||||
it.each(SyncTargetRegistry.allIds().map(id => ({
|
||||
id,
|
||||
name: SyncTargetRegistry.idToName(id),
|
||||
expected: SyncTargetRegistry.isJoplinServerOrCloud(id),
|
||||
})))('should set joplinServerConnected to $expected when the sync target is $name', ({ id, expected }) => {
|
||||
const getWhenClauseContext = (syncTarget: number) => {
|
||||
const applicationState = {
|
||||
...defaultState,
|
||||
settings: {
|
||||
'sync.target': syncTarget,
|
||||
},
|
||||
};
|
||||
return stateToWhenClauseContext(applicationState);
|
||||
};
|
||||
|
||||
const whenClauseContext = getWhenClauseContext(id);
|
||||
expect(whenClauseContext.joplinServerConnected).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user