Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Tucchhaa committed Apr 14, 2024
1 parent 10e0dfe commit 496b58f
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
52 changes: 52 additions & 0 deletions lib/__tests__/__snapshots__/text.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,58 @@ Array [
]
`;

exports[`text linkify parses half-width brackets correctly 1`] = `
Array [
<a
href="http://foo.com/blah_(a)_(b)"
target="_blank"
>
http://foo.com/blah_(a)_(b)
</a>,
" (",
<a
href="http://foo.com/blah_(a)_(b)"
target="_blank"
>
http://foo.com/blah_(a)_(b)
</a>,
") ",
<a
href="http://foo.com/blah_(a)_(b)"
target="_blank"
>
http://foo.com/blah_(a)_(b)
</a>,
")",
]
`;

exports[`text linkify parses full-width brackets correctly 1`] = `
Array [
<a
href="http://foo.com/blah_(a)_(b)"
target="_blank"
>
http://foo.com/blah_(a)_(b)
</a>,
" (",
<a
href="http://foo.com/blah_(a)_(b)"
target="_blank"
>
http://foo.com/blah_(a)_(b)
</a>,
") ",
<a
href="http://foo.com/blah_(a)_(b)"
target="_blank"
>
http://foo.com/blah_(a)_(b)
</a>,
")",
]
`;

exports[`text linkify sets prop to link 1`] = `
Array [
"Please go to ",
Expand Down
22 changes: 22 additions & 0 deletions lib/__tests__/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down

0 comments on commit 496b58f

Please sign in to comment.