-
-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7205 from keymanapp/fix/web/non-whitespace-wordbr…
…eaks fix(common/models): fixes quote-adjacent pred-text suggestions
- Loading branch information
Showing
7 changed files
with
268 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
common/predictive-text/unit_tests/headless/transform-utils.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
var assert = require('chai').assert; | ||
|
||
let TransformUtils = require('../../../web/lm-worker/build/intermediate.js').TransformUtils; | ||
|
||
describe('TransformUtils', function () { | ||
describe('isWhitespace', function () { | ||
it("should not match a string containing standard alphabetic characters", function () { | ||
let testTransforms = [{ | ||
insert: "a ", | ||
deleteLeft: 0 | ||
}, { | ||
insert: " a", | ||
deleteLeft: 0 | ||
}, { | ||
insert: "ab", | ||
deleteLeft: 0 | ||
}]; | ||
|
||
testTransforms.forEach((transform) => assert.isFalse(TransformUtils.isWhitespace(transform), `failed with: '${transform.insert}'`)); | ||
}); | ||
|
||
it("should match a simple ' ' transform", function() { | ||
transform = { | ||
insert: " ", | ||
deleteLeft: 0 | ||
}; | ||
|
||
assert.isTrue(TransformUtils.isWhitespace(transform)); | ||
}); | ||
|
||
it("should match a simple ' ' transform with delete-left", function() { | ||
transform = { | ||
insert: " ", | ||
deleteLeft: 1 | ||
}; | ||
|
||
assert.isTrue(TransformUtils.isWhitespace(transform)); | ||
}); | ||
|
||
it("should match a transform consisting of multiple characters of only whitespace", function() { | ||
transform = { | ||
insert: " \n\r\u00a0\t\u2000 ", | ||
deleteLeft: 0 | ||
}; | ||
|
||
assert.isTrue(TransformUtils.isWhitespace(transform)); | ||
}); | ||
|
||
it("stress tests", function() { | ||
transform = { | ||
insert: " \n\r\u00a0\ta\u2000 ", // the 'a' should cause failure. | ||
deleteLeft: 0 | ||
}; | ||
|
||
assert.isFalse(TransformUtils.isWhitespace(transform)); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.