Skip to content

Commit b7177ee

Browse files
committed
Add unit test for multiple occurrences in the same node
1 parent bcd53c1 commit b7177ee

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,30 @@ test('findAndReplace', async function (t) {
464464
])
465465
)
466466
})
467+
468+
await t.test(
469+
'should replace multiple matches in the same node',
470+
async function () {
471+
const tree = create()
472+
473+
findAndReplace(tree, [/(emph|sis)/, 'foo'])
474+
475+
assert.deepEqual(
476+
tree,
477+
u('paragraph', [
478+
u('text', 'Some '),
479+
u('emphasis', [u('text', 'foo'), u('text', 'a'), u('text', 'foo')]),
480+
u('text', ', '),
481+
u('strong', [u('text', 'importance')]),
482+
u('text', ', '),
483+
u('text', 'alert(1)'),
484+
u('text', ' '),
485+
u('inlineCode', 'code'),
486+
u('text', '.')
487+
])
488+
)
489+
}
490+
)
467491
})
468492

469493
function create() {

0 commit comments

Comments
 (0)