-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
134 additions
and
857 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
17 changes: 17 additions & 0 deletions
17
...s/content/extensions/component-groups/examples/ExpandableText/ExpandableText.md
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,17 @@ | ||
--- | ||
section: extensions | ||
subsection: Component groups | ||
id: ExpandableText | ||
source: react | ||
propComponents: ['ExpandableText'] | ||
--- | ||
|
||
import ExpandableText from "@patternfly/react-component-groups/dist/dynamic/ExpandableText"; | ||
|
||
## Component usage | ||
|
||
### Truncate component | ||
|
||
```js file="./ExpandableTextExample.tsx" | ||
|
||
``` |
6 changes: 6 additions & 0 deletions
6
...ocs/content/extensions/component-groups/examples/ExpandableText/ExpandableTextExample.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,6 @@ | ||
import React from 'react'; | ||
import ExpandableText from "@patternfly/react-component-groups/dist/dynamic/ExpandableText"; | ||
|
||
|
||
export const BasicExample: React.FunctionComponent = () => <ExpandableText text="This is a long string that will be truncated" length={10} />; | ||
|
17 changes: 0 additions & 17 deletions
17
...tternfly-docs/content/extensions/component-groups/examples/Truncate/Truncate.md
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
...patternfly-docs/content/extensions/component-groups/examples/Truncate/TruncateExample.tsx
This file was deleted.
Oops, something went wrong.
79 changes: 79 additions & 0 deletions
79
packages/module/src/ExpandableText/ExpandableText.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,79 @@ | ||
import React from 'react'; | ||
import { render } from '@testing-library/react'; | ||
import ExpandableText from './ExpandableText'; | ||
|
||
const text = `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore | ||
et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea | ||
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla | ||
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est | ||
laborum.`; | ||
|
||
describe('ExpandableText component', () => { | ||
describe('should render correctly', () => { | ||
[true, false].forEach((isInline) => { | ||
Check failure on line 13 in packages/module/src/ExpandableText/ExpandableText.test.tsx GitHub Actions / call-build-lint-test-workflow / lint
|
||
describe(isInline ? 'inline' : 'block', () => { | ||
it('without length specified', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('with short length', () => { | ||
const wrapper = render(<ExpandableText text={text} length={2} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('clicking on expand toggles to collapse', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} expandText="Custom expand" collapseText="Custom collapse" />); | ||
// wrapper.find('.ins-c-expand-button').first().simulate('click'); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('custom expande button', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} expandText="Custom expand" collapseText="Custom collapse" />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('custom button titles', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} expandText="Custom expand" collapseText="Custom collapse" />); | ||
// wrapper.find('.ins-c-expand-button').first().simulate('click'); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('clicking on expand toggles to collapse', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} expandText="Custom expand" collapseText="Custom collapse" />); | ||
// wrapper.find('.ins-c-expand-button').first().simulate('click'); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('custom expande button', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} expandText="Custom expand" collapseText="Custom collapse" />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('custom button titles', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} expandText="Custom expand" collapseText="Custom collapse" />); | ||
// wrapper.find('.ins-c-expand-button').first().simulate('click'); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('when text length is less than user specified length', () => { | ||
const wrapper = render(<ExpandableText text={text} inline={isInline} length={1000} />); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('hovering over toggles to collapse', () => { | ||
const wrapper = render(<ExpandableText length={50} inline={isInline} text={text} expandOnMouseOver hideExpandText />); | ||
// const eventElement = isInline ? wrapper.find('.ins-c-ExpandableText').first() : wrapper.find('.ins-c-ExpandableText').first().children().first(); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
|
||
// eventElement.simulate('mouseenter'); | ||
expect(wrapper).toMatchSnapshot(); | ||
|
||
// eventElement.simulate('mouseleave'); | ||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default } from './ExpandableText'; | ||
export { default as ExpandableText } from './ExpandableText'; | ||
export * from './ExpandableText'; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.