mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-12-27 02:23:28 +08:00
037ce35ca7
On my Ubuntu 20.10 some of these tests currently fail as words cannot be learned. Needs some mor debugging.
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
/* eslint global-require: 0 */
|
|
import fs from 'fs';
|
|
import { Spellchecker } from 'mailspring-exports';
|
|
|
|
describe('Spellchecker', function spellcheckerTests() {
|
|
beforeEach(() => {
|
|
this.customDict = '{}';
|
|
spyOn(fs, 'writeFile').andCallFake((path, customDict, cb) => {
|
|
this.customDict = customDict;
|
|
cb();
|
|
});
|
|
spyOn(fs, 'readFile').andCallFake((path, cb) => {
|
|
cb(null, this.customDict);
|
|
});
|
|
});
|
|
|
|
it('does not call spellchecker when word has already been learned', () => {
|
|
Spellchecker.learnWord('mispaelled');
|
|
const misspelled = Spellchecker.isMisspelled('mispaelled');
|
|
expect(misspelled).toBe(false);
|
|
});
|
|
|
|
describe('when a custom word is added', () => {
|
|
this.customWord = 'becaause';
|
|
|
|
beforeEach(() => {
|
|
expect(Spellchecker.isMisspelled(this.customWord)).toEqual(true);
|
|
Spellchecker.learnWord(this.customWord);
|
|
});
|
|
|
|
afterEach(() => {
|
|
Spellchecker.unlearnWord(this.customWord);
|
|
expect(Spellchecker.isMisspelled(this.customWord)).toEqual(true);
|
|
});
|
|
|
|
it("doesn't think it's misspelled", () => {
|
|
expect(Spellchecker.isMisspelled(this.customWord)).toEqual(false);
|
|
});
|
|
|
|
it('maintains it across instances', () => {
|
|
const Spellchecker2 = require('../src/spellchecker').default;
|
|
expect(Spellchecker2.isMisspelled(this.customWord)).toEqual(false);
|
|
});
|
|
});
|
|
});
|