-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(toolbarFilter): rhcloud-25607 pf wrapper, expand checks (#1165)
- Loading branch information
Showing
7 changed files
with
395 additions
and
4 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
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
82 changes: 82 additions & 0 deletions
82
src/components/toolbar/__tests__/__snapshots__/toolbarFilter.test.js.snap
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,82 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`ToolbarFilter Component should display basic chips: portal 1`] = ` | ||
[ | ||
<ToolbarItem | ||
variant="chip-group" | ||
> | ||
<ChipGroup | ||
aria-label="Chip group category" | ||
categoryName="loremIpsum" | ||
closeBtnAriaLabel="Close chip group" | ||
collapsedText="\${remaining} more" | ||
defaultIsOpen={false} | ||
expandedText="Show Less" | ||
isClosable={false} | ||
numChips={3} | ||
onClick={[Function]} | ||
onOverflowChipClick={[Function]} | ||
tooltipPosition="top" | ||
> | ||
<Chip | ||
className="" | ||
closeBtnAriaLabel="close" | ||
component="div" | ||
isOverflowChip={false} | ||
isReadOnly={false} | ||
onClick={[Function]} | ||
tooltipPosition="top" | ||
> | ||
lorem | ||
</Chip> | ||
<Chip | ||
className="" | ||
closeBtnAriaLabel="close" | ||
component="div" | ||
isOverflowChip={false} | ||
isReadOnly={false} | ||
onClick={[Function]} | ||
tooltipPosition="top" | ||
> | ||
hello world | ||
</Chip> | ||
</ChipGroup> | ||
</ToolbarItem>, | ||
"dolor sit test", | ||
] | ||
`; | ||
|
||
exports[`ToolbarFilter Component should export specific context hooks: context hooks 1`] = ` | ||
{ | ||
"useToolbarContentContext": [Function], | ||
"useToolbarContext": [Function], | ||
} | ||
`; | ||
|
||
exports[`ToolbarFilter Component should render a basic component: basic 1`] = ` | ||
<toolbarfilter | ||
props="{ | ||
"categoryName": "loremIpsum", | ||
"chips": [ | ||
"lorem", | ||
{ | ||
"key": "ipsum", | ||
"node": "hello world" | ||
} | ||
], | ||
"children": [ | ||
{} | ||
], | ||
"chipGroupCollapsedText": null, | ||
"chipGroupExpandedText": null, | ||
"deleteChipGroup": null, | ||
"showToolbarItem": true | ||
}" | ||
> | ||
<div | ||
class="pf-c-toolbar__item" | ||
> | ||
lorem ipsum | ||
</div> | ||
</toolbarfilter> | ||
`; |
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,35 @@ | ||
import React from 'react'; | ||
import ReactDom from 'react-dom'; | ||
import { ToolbarFilter, useToolbarContentContext, useToolbarContext } from '../toolbarFilter'; | ||
|
||
describe('ToolbarFilter Component', () => { | ||
it('should render a basic component', () => { | ||
const props = { | ||
categoryName: 'loremIpsum', | ||
chips: ['lorem', { key: 'ipsum', node: 'hello world' }] | ||
}; | ||
const component = renderComponent(<ToolbarFilter {...props}>lorem ipsum</ToolbarFilter>); | ||
|
||
expect(component).toMatchSnapshot('basic'); | ||
}); | ||
|
||
it('should export specific context hooks', () => { | ||
expect({ useToolbarContentContext, useToolbarContext }).toMatchSnapshot('context hooks'); | ||
}); | ||
|
||
it('should display basic chips', () => { | ||
const mockPortal = jest.fn(); | ||
const spyReactDom = jest.spyOn(ReactDom, 'createPortal').mockImplementation(mockPortal); | ||
|
||
const props = { | ||
categoryName: 'loremIpsum', | ||
chips: ['lorem', { key: 'ipsum', node: 'hello world' }], | ||
useToolbarContentContext: () => ({ chipContainerRef: { current: 'dolor sit test' } }) | ||
}; | ||
renderComponent(<ToolbarFilter {...props}>lorem ipsum</ToolbarFilter>); | ||
|
||
expect(mockPortal.mock.calls.pop()).toMatchSnapshot('portal'); | ||
|
||
spyReactDom.mockClear(); | ||
}); | ||
}); |
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
Oops, something went wrong.