Skip to content

Commit

Permalink
Replace links with a warning
Browse files Browse the repository at this point in the history
Replace links with "[link rimosso]"
  • Loading branch information
Garma00 committed Jan 25, 2024
1 parent 46fdad6 commit eaad9b4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions EmailNotification/__tests__/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,34 @@ describe("removeLinks", () => {
test("should return the string without the url if a simple url is contained", () => {
const simpleLink = "https://asimplelink.com/";
const baseText = `A simple text`;
expect(removeLinks(`${baseText}${simpleLink}`)).toBe(baseText);
expect(removeLinks(`${baseText} ${simpleLink}`)).toBe(
`${baseText} [link rimosso]`
);
});

test("should return the string without the url if more than one simple url are contained", () => {
const simpleLink = "https://asimplelink.com/";
const baseText = `A simple text`;
expect(
removeLinks(
`${baseText} ${simpleLink} this is another link ${simpleLink}`
)
).toBe(`${baseText} [link rimosso] this is another link [link rimosso]`);
});

test("should return the string without the url if an url with query params is contained", () => {
const simpleLink = "https://asimplelink.com/?qp1=value";
const baseText = `A simple text`;
expect(removeLinks(`${baseText}${simpleLink}`)).toBe(baseText);
expect(removeLinks(`${baseText} ${simpleLink}`)).toBe(
`${baseText} [link rimosso]`
);
});

test("should return the string without the url if an url with query params and # is contained ", () => {
const simpleLink = "https://asimplelink.com/?qp1=value#header";
const baseText = `A simple text`;
expect(removeLinks(`${baseText}${simpleLink}`)).toBe(baseText);
expect(removeLinks(`${baseText} ${simpleLink}`)).toBe(
`${baseText} [link rimosso]`
);
});
});

0 comments on commit eaad9b4

Please sign in to comment.