diff --git a/spec/highlight-support.spec.js b/spec/highlight-support.spec.js
index bcc410e0..1a6f9c48 100644
--- a/spec/highlight-support.spec.js
+++ b/spec/highlight-support.spec.js
@@ -327,6 +327,36 @@ ke The
World Go Round`)
expect(this.getHtml()).to.equal(expectedHtml)
})
+ it('limits start and end values to text range', function () {
+ setupHighlightEnv(this, 'ab')
+ this.highlightRange('ab', 'myId', -1, 100)
+ const expectedHtml = this.formatHtml(
+ `ab`
+ )
+
+ expect(this.getHtml()).to.equal(expectedHtml)
+ })
+
+ it('always selects the first character if values are too small', function () {
+ setupHighlightEnv(this, 'ab')
+ this.highlightRange('ab', 'myId', 0, 0)
+ const expectedHtml = this.formatHtml(
+ `ab`
+ )
+
+ expect(this.getHtml()).to.equal(expectedHtml)
+ })
+
+ it('always selects the last character if values are too large', function () {
+ setupHighlightEnv(this, 'ab')
+ this.highlightRange('ab', 'myId', 2, 5)
+ const expectedHtml = this.formatHtml(
+ `ab`
+ )
+
+ expect(this.getHtml()).to.equal(expectedHtml)
+ })
+
it('handles a
tag without whitespaces', function () {
setupHighlightEnv(this, 'a
b')
this.highlightRange('b', 'myId', 1, 2)
diff --git a/spec/selection.spec.js b/spec/selection.spec.js
index ccdc0fb9..4e2bd180 100644
--- a/spec/selection.spec.js
+++ b/spec/selection.spec.js
@@ -142,6 +142,17 @@ describe('Selection', function () {
})
})
+ describe('getTextRange()', function () {
+
+ it('handles a zero width non-break space', function () {
+ const oneWord = createElement('