Skip to content

Commit

Permalink
docs: add versioned link test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
addetz committed Dec 12, 2024
1 parent d9a8192 commit 150e2b8
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/components/VersionedLink/VersionedLink.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,19 @@ describe("Versioned link", () => {
expect(link).toBe(url);
});

it("latest version with component", () => {
prevVersionPath = "";
const componentText = "Component text";
const component = <p>{componentText}</p>;
const url = "/path/url";
render(<VersionedLink component={component} url={url} />);
const componentRender = screen.getByText(componentText);
expect(componentRender).not.toBeNull();
const link = screen.getByRole("link").getAttribute("href");
expect(link).not.toBeNull();
expect(link).toBe(url);
});

it("previous version", () => {
prevVersionPath = "/v4.3.1";
const text = "Test link";
Expand All @@ -30,6 +43,19 @@ describe("Versioned link", () => {
expect(link).toBe(prevVersionPath.concat(url));
});

it("previous version with component", () => {
prevVersionPath = "/v4.3.1";
const componentText = "Component text";
const component = <p>{componentText}</p>;
const url = "/path/url";
render(<VersionedLink component={component} url={url} />);
const componentRender = screen.getByText(componentText);
expect(componentRender).not.toBeNull();
const link = screen.getByRole("link").getAttribute("href");
expect(link).not.toBeNull();
expect(link).toBe(prevVersionPath.concat(url));
});

it("url with back dots", () => {
prevVersionPath = "";
const text = "Test link";
Expand Down

0 comments on commit 150e2b8

Please sign in to comment.