1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/packages/app-desktop/gui/WindowCommandsAndDialogs/commands/showSpellCheckerMenu.test.ts
Henry Heino 4a88d6ff7a
Desktop: Multiple window support (#11181)
Co-authored-by: Laurent Cozic <laurent22@users.noreply.github.com>
2024-11-08 15:32:05 +00:00

52 lines
1.3 KiB
TypeScript

import { runtime } from './showSpellCheckerMenu';
import { AppState } from '../../../app.reducer';
jest.mock('../../../services/bridge', () => ({
__esModule: true,
default: () => ({
Menu: {
buildFromTemplate: jest.fn().mockReturnValue({
popup: jest.fn(),
}),
},
}),
}));
describe('mapStateToTitle', () => {
test('should return null if spellchecker.enabled is false', () => {
const mockState: Partial<AppState> = {
settings: {
'spellChecker.enabled': false,
'spellChecker.languages': ['en-GB'],
},
};
const result = runtime().mapStateToTitle(mockState);
expect(result).toBeNull();
});
test('should return null if spellChecker.languages is empty', () => {
const mockState: Partial<AppState> = {
settings: {
'spellChecker.enabled': true,
'spellChecker.languages': [],
},
};
const result = runtime().mapStateToTitle(mockState);
expect(result).toBeNull();
});
test('should return list of countryDisplayName with correct format', () => {
const mockState: Partial<AppState> = {
settings: {
'spellChecker.enabled': true,
'spellChecker.languages': ['en-GB', 'en-US', 'en-CA', 'es-ES', 'es-MX'],
},
};
const result = runtime().mapStateToTitle(mockState);
expect(result).toBe('en, es');
});
});