Skip to content

Commit 716f9d8

Browse files
committed
Added test
1 parent ea4f34c commit 716f9d8

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,14 @@ test('Returns an array', t => {
1111
t.true(Array.isArray(replaceString('blah', 'blah', x => x)));
1212
});
1313

14+
test('Returns correct character offsets', t => {
15+
const correctOffsets = [6, 17];
16+
const charOffsets = [];
17+
18+
replaceString('Hey there, stranger', 'er', (m, i, o) => charOffsets.push(o));
19+
t.deepEqual(charOffsets, correctOffsets);
20+
});
21+
1422
test('Works with matching groups', t => {
1523
t.deepEqual(
1624
replaceString('hey there', /(hey)/g, x => ({ worked: x })),

0 commit comments

Comments
 (0)