Skip to content

Commit

Permalink
add tests for faulty regex with some characters
Browse files Browse the repository at this point in the history
  • Loading branch information
d8vjork committed Dec 21, 2023
1 parent 59a314d commit 36d12be
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,23 @@ test('test highlight adding dynamically an element via reactivity', async () =>
// FIXME: unhighlightElements function when update is breaking HTML elements!
// expect(wrapperHtml).toContain('<a href="/foo" target="_blank" data-highlighted="1"><span style="background: rgb(235, 231, 110);">ipsum</span></a>');

wrapper.unmount();
});

test('test highlight regex does not crash with some characters', async () => {
const wrapper = mount(defineComponent({
directives: { "highlight": vHighlight },
template: `<div v-highlight="['**ipsum**', 'hello', 'foo']">
<h1>Lorem **ipsum**</h1>
<p>Hello lorem, I'm a foobar doing much <a href="/foo" target="_blank">ipsum</a></p>
<footer>test moar ipsums</footer>
</div>`
}));

const wrapperHtml = wrapper.html();

expect(wrapperHtml).toContain('<h1 data-highlighted="1">Lorem <span style="background: rgb(235, 231, 110);">**ipsum**</span></h1>');
expect(wrapperHtml).not.toContain('<a href="/foo" target="_blank" data-highlighted="1"><span style="background: rgb(235, 231, 110);">ipsum</span></a>');

wrapper.unmount();
});

0 comments on commit 36d12be

Please sign in to comment.