mirror of
https://github.com/keymanapp/keyman.git
synced 2026-10-06 14:07:32 +00:00
fix(web): patch up unit tests for change to worker reversion pattern
This commit is contained in:
parent
eadbfc625f
commit
6c847422df
2 changed files with 9 additions and 8 deletions
|
|
@ -223,17 +223,17 @@ export class ModelCompositor {
|
|||
*
|
||||
* @param suggestion Suggestion selected, whether automatically or by the user.
|
||||
* @param context The context to which the suggestion should be applied.
|
||||
* @param postTransform The original transform that is being replaced by the applied suggestion (!)
|
||||
* @param originalInput The original transform that is being replaced by the applied suggestion (!)
|
||||
* @returns
|
||||
*/
|
||||
acceptSuggestion(suggestion: Suggestion, context: Context, postTransform?: Transform): Reversion {
|
||||
acceptSuggestion(suggestion: Suggestion, context: Context, originalInput?: Transform): Reversion {
|
||||
// Step 1: re-use the original input Transform as the reversion's Transform.
|
||||
// The Web engine will restore the original state of the context before accepting
|
||||
// and before reverting; all we need to do is put the original keystroke back in place.
|
||||
let reversionTransform: Transform = postTransform;
|
||||
let reversionTransform: Transform = originalInput ?? { insert: '', deleteLeft: 0 };
|
||||
|
||||
// Step 2: building the proper 'displayAs' string for the Reversion
|
||||
const postContext = models.applyTransform(postTransform, context);
|
||||
const postContext = originalInput ? models.applyTransform(originalInput, context) : context;
|
||||
|
||||
let revertedPrefix: string;
|
||||
let postContextTokenization = this.tokenize(postContext);
|
||||
|
|
|
|||
|
|
@ -663,7 +663,7 @@ describe('ModelCompositor', function() {
|
|||
let appliedContext = models.applyTransform(baseSuggestion.transform, baseContext);
|
||||
assert.equal(appliedContext.left, "hello ");
|
||||
|
||||
let revertedContext = models.applyTransform(reversion.transform, appliedContext);
|
||||
let revertedContext = models.applyTransform(reversion.transform, baseContext);
|
||||
assert.deepEqual(revertedContext, unappliedContext);
|
||||
|
||||
// Check #2: Are the correct display strings built, depending on the active model's punctuation?
|
||||
|
|
@ -706,7 +706,7 @@ describe('ModelCompositor', function() {
|
|||
let appliedContext = models.applyTransform(baseSuggestion.transform, baseContext);
|
||||
assert.equal(appliedContext.left, "hello world ");
|
||||
|
||||
let revertedContext = models.applyTransform(reversion.transform, appliedContext);
|
||||
let revertedContext = models.applyTransform(reversion.transform, baseContext);
|
||||
assert.deepEqual(revertedContext, unappliedContext);
|
||||
|
||||
// Check #2: Are the correct display strings built, depending on the active model's punctuation?
|
||||
|
|
@ -742,7 +742,7 @@ describe('ModelCompositor', function() {
|
|||
let appliedContext = models.applyTransform(baseSuggestion.transform, baseContext);
|
||||
assert.equal(appliedContext.left, "hello world ");
|
||||
|
||||
let revertedContext = models.applyTransform(reversion.transform, appliedContext);
|
||||
let revertedContext = models.applyTransform(reversion.transform, baseContext);
|
||||
assert.deepEqual(revertedContext, unappliedContext);
|
||||
|
||||
// Check #2: Are the correct display strings built, depending on the active model's punctuation?
|
||||
|
|
@ -785,7 +785,8 @@ describe('ModelCompositor', function() {
|
|||
let appliedContext = models.applyTransform(baseSuggestion.transform, baseContext);
|
||||
assert.equal(appliedContext.left, "hello ");
|
||||
|
||||
let revertedContext = models.applyTransform(reversion.transform, appliedContext);
|
||||
let revertedContext = models.applyTransform(reversion.transform, baseContext);
|
||||
assert.equal(revertedContext.left, "hi");
|
||||
assert.deepEqual(revertedContext, unappliedContext);
|
||||
|
||||
// Check #2: Are the correct display strings built, depending on the active model's punctuation?
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue