2024-02-26 12:27:34 +02:00
|
|
|
import { runtime } from './showSpellCheckerMenu';
|
|
|
|
import { AppState } from '../../../app.reducer';
|
|
|
|
|
|
|
|
jest.mock('../../../services/bridge', () => ({
|
|
|
|
__esModule: true,
|
|
|
|
default: () => ({
|
|
|
|
Menu: {
|
|
|
|
buildFromTemplate: jest.fn().mockReturnValue({
|
|
|
|
popup: jest.fn(),
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
}),
|
|
|
|
}));
|
|
|
|
|
2024-02-26 18:53:48 +02:00
|
|
|
describe('mapStateToTitle', () => {
|
2024-02-26 12:27:34 +02:00
|
|
|
|
|
|
|
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');
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|