Skip to content

Commit

Permalink
Merge pull request #83 from saperdadsk/saperd/nan_fix_test
Browse files Browse the repository at this point in the history
Adds a test checking that we handle empty string styles
  • Loading branch information
bvaughn authored Feb 24, 2024
2 parents 323d599 + 64eacd6 commit e841d37
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/AutoSizer.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe("AutoSizer", () => {
{
bar = 123,
ChildComponent = DefaultChildComponent,
excludeWrapperStyling = false,
foo = 456,
height = 100,
paddingBottom = 0,
Expand Down Expand Up @@ -110,7 +111,7 @@ describe("AutoSizer", () => {
const root = createRoot(container);
act(() => {
root.render(
<div style={wrapperStyle}>
<div style={excludeWrapperStyling ? undefined : wrapperStyle}>
<AutoSizer
disableHeight={disableHeight as any}
disableWidth={disableWidth as any}
Expand Down Expand Up @@ -144,6 +145,18 @@ describe("AutoSizer", () => {
expect(container.textContent).toContain("width:200");
});

it("should not render children for elements with empty computed styles", () => {
mockOffsetSize(0, 0);

renderHelper({
excludeWrapperStyling: true,
height: 0,
width: 0,
});

expect(container.textContent).toEqual("");
});

it("should account for padding when calculating the available width and height", () => {
renderHelper({
paddingBottom: 10,
Expand Down

0 comments on commit e841d37

Please sign in to comment.