diff --git a/src/EmojiCharString.js b/src/EmojiCharString.js index c5fadd5..a3813a5 100644 --- a/src/EmojiCharString.js +++ b/src/EmojiCharString.js @@ -5,6 +5,8 @@ class EmojiCharString extends String { if (typeof string !== 'string') { throw new Error('Input must be a string') } + // Compiled code includes || logic, test cases can not cover some branch. + /* istanbul ignore next */ super(string) this._string = string this._match = string.match(astralRange) || [] @@ -87,6 +89,7 @@ class EmojiCharString extends String { if (separator === '') { return this._match.slice(0) } + /* istanbul ignore next */ return super.split(separator) } @@ -95,6 +98,7 @@ class EmojiCharString extends String { } indexOf (ch, from) { + /* istanbul ignore next */ const idx = super.indexOf(ch, from) if (idx === -1) { return -1 diff --git a/test/test.js b/test/test.js index 7a93376..13db061 100644 --- a/test/test.js +++ b/test/test.js @@ -244,5 +244,6 @@ describe('EmojiCharString Class indexOf method', () => { assert.equal(emojiStr.indexOf('o'), 2) assert.equal(emojiStr.indexOf('o', -1), 2) assert.equal(emojiStr.indexOf('o', emojiStrLen + 1), -1) + assert.equal(emojiStr.indexOf(''), 0) }) })