1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-21 09:38:01 +02:00
joplin/packages/app-desktop/gui/MainScreen/commands/showSpellCheckerMenu.test.ts

52 lines
1.3 KiB
TypeScript
Raw Normal View History

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