-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(#2109): tabs query string and initial tab issue
- Loading branch information
1 parent
73d7625
commit 135f0f8
Showing
3 changed files
with
96 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,44 @@ | ||
import { render } from "@testing-library/react"; | ||
import { GoATab } from "./tab"; | ||
import { GoABadge } from "../badge/badge"; | ||
|
||
describe("GoATab", () => { | ||
it("should render successfully", () => { | ||
it("should render string heading as attribute", () => { | ||
const { container } = render( | ||
<GoATab heading="Profile"> | ||
<p> | ||
<b>Profile:</b> Lorem ipsum dolor sit amet, consectetur adipiscing | ||
elit, sed do eiusmod tempor incididunt ut labore et dolore magna | ||
aliqua. | ||
<b>Profile:</b> Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do | ||
eiusmod tempor incididunt ut labore et dolore magna aliqua. | ||
</p> | ||
</GoATab> | ||
</GoATab>, | ||
); | ||
expect(container.querySelector("goa-tab")).toBeTruthy(); | ||
const heading = container.querySelector("[slot='heading']"); | ||
expect(heading?.innerHTML).toContain("Profile"); | ||
|
||
const tabElement = container.querySelector("goa-tab"); | ||
expect(tabElement).toBeTruthy(); | ||
expect(tabElement?.getAttribute("heading")).toBe("Profile"); | ||
const content = container.querySelector("p"); | ||
expect(content?.innerHTML).toContain("Lorem ipsum dolor sit amet"); | ||
}); | ||
|
||
it("should render complex heading content using slot", () => { | ||
const { container } = render( | ||
<GoATab | ||
heading={ | ||
<> | ||
Completed <GoABadge type="midtone" content="1" /> | ||
</> | ||
} | ||
> | ||
<p>Test content</p> | ||
</GoATab>, | ||
); | ||
|
||
const tabElement = container.querySelector("goa-tab"); | ||
expect(tabElement).toBeTruthy(); | ||
const heading = container.querySelector("[slot='heading']"); | ||
expect(heading).toBeTruthy(); | ||
expect(heading?.textContent?.trim()).toContain("Completed"); | ||
const badge = container.querySelector("goa-badge"); | ||
expect(badge).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters