Skip to content

Commit

Permalink
Add unit test for adjacent matches in the same text node
Browse files Browse the repository at this point in the history
Closes GH-4.
Related-to GH-5.
  • Loading branch information
lpsinger authored Sep 12, 2023
1 parent bcd53c1 commit fbe1d6b
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,28 @@ test('findAndReplace', async function (t) {
])
)
})

await t.test(
'should replace multiple matches in the same node',
async function () {
const tree = create()

findAndReplace(tree, [/(emph|sis)/g, 'foo'])

assert.deepEqual(
tree,
u('paragraph', [
u('text', 'Some '),
u('emphasis', [u('text', 'foo'), u('text', 'a'), u('text', 'foo')]),
u('text', ', '),
u('strong', [u('text', 'importance')]),
u('text', ', and '),
u('inlineCode', 'code'),
u('text', '.')
])
)
}
)
})

function create() {
Expand Down

0 comments on commit fbe1d6b

Please sign in to comment.