Merge pull request #1817 from keymanapp/lmlayer-string-normalize

[LMLayer] Partial workaround for lack of  String.prototype.normalize() support.
This commit is contained in:
Eddie Antonio Santos 2019-06-07 08:53:19 -06:00 committed by GitHub
commit a8dfaaa5aa
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 51 additions and 8 deletions

View file

@ -154,7 +154,36 @@ describe('LMLayerWorker trie model for word lists', function() {
firstResults.map(s => s.displayAs)
);
});
})
});
describe('The default key function', function () {
it('uses the default key function', function () {
var model = new TrieModel(jsonFixture('tries/accented'));
// «nai| » [Send]
// [ ??? ] [ naïve ] [ ??? ]
var [suggestion] = model.predict({
insert: 'i', deleteLeft: 0
}, {
left: 'na',
startOfBuffer: false,
endOfBuffer: true
}).map(getSample);
assert.strictEqual(suggestion.displayAs, 'naïve');
// «Lets get some pho| » [Send]
// [ ??? ] [ phở ] [ ??? ]
var [suggestion] = model.predict({
insert: 'o', deleteLeft: 0
}, {
left: 'Lets get some ph',
startOfBuffer: false,
endOfBuffer: true
}).map(getSample);
assert.strictEqual(suggestion.displayAs, 'phở');
});
});
it('replaces the entire typed word when a suggestion is accepted', function () {
// Ensure that all input is lower-cased when we try to look it up.

View file

@ -0,0 +1 @@
{"type":"internal","weight":1,"values":["p","n"],"children":{"p":{"type":"leaf","weight":1,"entries":[{"key":"pho","weight":1,"content":"phở"}]},"n":{"type":"leaf","weight":1,"entries":[{"key":"naive","weight":1,"content":"naïve"}]}}}

File diff suppressed because one or more lines are too long