From 496b58f7cce4533dc1918fb8112eb23bca7f7e01 Mon Sep 17 00:00:00 2001 From: Eldar Iusupzhanov Date: Sun, 14 Apr 2024 17:19:44 +0800 Subject: [PATCH] add tests --- lib/__tests__/__snapshots__/text.tsx.snap | 52 +++++++++++++++++++++++ lib/__tests__/text.tsx | 22 ++++++++++ 2 files changed, 74 insertions(+) diff --git a/lib/__tests__/__snapshots__/text.tsx.snap b/lib/__tests__/__snapshots__/text.tsx.snap index e4b51dcf..133fe4b6 100644 --- a/lib/__tests__/__snapshots__/text.tsx.snap +++ b/lib/__tests__/__snapshots__/text.tsx.snap @@ -86,6 +86,58 @@ Array [ ] `; +exports[`text linkify parses half-width brackets correctly 1`] = ` +Array [ + + http://foo.com/blah_(a)_(b) + , + " (", + + http://foo.com/blah_(a)_(b) + , + ") ", + + http://foo.com/blah_(a)_(b) + , + ")", +] +`; + +exports[`text linkify parses full-width brackets correctly 1`] = ` +Array [ + + http://foo.com/blah_(a)_(b) + , + " (", + + http://foo.com/blah_(a)_(b) + , + ") ", + + http://foo.com/blah_(a)_(b) + , + ")", +] +`; + exports[`text linkify sets prop to link 1`] = ` Array [ "Please go to ", diff --git a/lib/__tests__/text.tsx b/lib/__tests__/text.tsx index 66bb69c6..ff906d94 100644 --- a/lib/__tests__/text.tsx +++ b/lib/__tests__/text.tsx @@ -73,6 +73,28 @@ describe('text', () => { }) ).toMatchSnapshot(); }); + + it('parses half-width brackets correctly', () => { + expect( + linkify( + 'http://foo.com/blah_(a)_(b) (http://foo.com/blah_(a)_(b)) http://foo.com/blah_(a)_(b))', + { + props: { target: '_blank' }, + } + ) + ).toMatchSnapshot(); + }); + + it('parses full-width brackets correctly', () => { + expect( + linkify( + 'http://foo.com/blah_(a)_(b) (http://foo.com/blah_(a)_(b)) http://foo.com/blah_(a)_(b))', + { + props: { target: '_blank' }, + } + ) + ).toMatchSnapshot(); + }); }); describe('nl2br', () => {