1
0
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:
Henry Heino
2025-10-03 06:32:57 -07:00
committed by GitHub
parent e24ebffba6
commit 1da7c54e5f
2 changed files with 21 additions and 3 deletions

View File

@@ -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) {

View File

@@ -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);
});
});