mirror of
https://github.com/prymitive/karma
synced 2026-05-05 03:16:51 +00:00
committed by
Łukasz Mierzwa
parent
11485dabfc
commit
ef2928ff13
@@ -122,6 +122,26 @@ describe("<SilenceComment />", () => {
|
||||
expect(tree.find("a[href='http://localhost/1234']")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("Correctly renders comments with spaces", () => {
|
||||
silence.ticketURL = "http://localhost/1234";
|
||||
silence.ticketID = "1234";
|
||||
silence.comment = "Ticket id 1234 should be linked here";
|
||||
const tree = MountedSilenceComment(false);
|
||||
expect(tree.html()).toContain(
|
||||
'<div class="components-managed-silence-comment "> Ticket id <a href="http://localhost/1234" target="_blank" rel="noopener noreferrer">1234</a> should be linked here</div>'
|
||||
);
|
||||
});
|
||||
|
||||
it("Correctly renders comments starting with a link", () => {
|
||||
silence.ticketURL = "http://localhost/1234";
|
||||
silence.ticketID = "1234";
|
||||
silence.comment = "1234 is the ticket id.";
|
||||
const tree = MountedSilenceComment(false);
|
||||
expect(tree.html()).toContain(
|
||||
'<div class="components-managed-silence-comment "><a href="http://localhost/1234" target="_blank" rel="noopener noreferrer">1234</a> is the ticket id.</div>'
|
||||
);
|
||||
});
|
||||
|
||||
it("collapseToggle is called when collapse icon is clicked", () => {
|
||||
const tree = MountedSilenceComment(true);
|
||||
const collapse = tree.find("svg.fa-chevron-down");
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { FC } from "react";
|
||||
import { Fragment, FC } from "react";
|
||||
|
||||
import { observer } from "mobx-react-lite";
|
||||
|
||||
@@ -57,14 +57,12 @@ const SilenceComment: FC<{
|
||||
}) => {
|
||||
const comment = silence.comment.split(" ").map((w, i) =>
|
||||
silence.ticketURL && w === silence.ticketID ? (
|
||||
<a
|
||||
key={i}
|
||||
href={silence.ticketURL}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
{silence.ticketID}
|
||||
</a>
|
||||
<Fragment key={i}>
|
||||
{i ? " " : null}
|
||||
<a href={silence.ticketURL} target="_blank" rel="noopener noreferrer">
|
||||
{silence.ticketID}
|
||||
</a>
|
||||
</Fragment>
|
||||
) : (
|
||||
" " + w
|
||||
)
|
||||
@@ -82,7 +80,7 @@ const SilenceComment: FC<{
|
||||
collapsed ? "text-truncate overflow-hidden" : ""
|
||||
}`}
|
||||
>
|
||||
{comment.map((w) => w)}
|
||||
{comment}
|
||||
</div>
|
||||
<div className="components-managed-silence-cite mt-1 d-flex flex-row">
|
||||
<span
|
||||
|
||||
Reference in New Issue
Block a user