forked from deephaven/deephaven-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some unit tests to ensure the height attribute gets set
- Loading branch information
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
plugins/ui/src/js/src/elements/spectrum/TabPanels.test.tsx
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import { | ||
Item, | ||
Tabs, | ||
TabList, | ||
Provider, | ||
defaultTheme, | ||
} from '@adobe/react-spectrum'; | ||
import TabPanels from './TabPanels'; | ||
import Flex from './Flex'; | ||
|
||
describe('TabPanels', () => { | ||
function renderTabPanelsChild(children: React.ReactNode) { | ||
return render( | ||
<Provider theme={defaultTheme}> | ||
<Tabs selectedKey="foo"> | ||
<TabList> | ||
<Item key="foo">Foo</Item> | ||
</TabList> | ||
<TabPanels> | ||
<Item key="foo">{children}</Item> | ||
</TabPanels> | ||
</Tabs> | ||
</Provider> | ||
); | ||
} | ||
|
||
it('should add height=100% prop to flex child', () => { | ||
const flexChild = <Flex data-testid="flex-child">Flex Child</Flex>; | ||
renderTabPanelsChild(flexChild); | ||
const flexElement = screen.queryByTestId('flex-child'); | ||
expect(flexElement).toHaveStyle('height: 100%'); | ||
}); | ||
|
||
it('should not add height=100% prop to non-flex child', () => { | ||
const nonFlexChild = <div data-testid="non-flex-child">Non-Flex Child</div>; | ||
renderTabPanelsChild(nonFlexChild); | ||
const nonFlexElement = screen.queryByTestId('non-flex-child'); | ||
expect(nonFlexElement).not.toHaveStyle('height: 100%'); | ||
}); | ||
}); |