-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(EllipsisText): use RootComponent for host
- Loading branch information
Showing
2 changed files
with
31 additions
and
15 deletions.
There are no files selected for viewing
36 changes: 26 additions & 10 deletions
36
packages/vkui/src/components/Typography/EllipsisText/EllipsisText.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 |
---|---|---|
@@ -1,24 +1,40 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import { render } from '@testing-library/react'; | ||
import { baselineComponent } from '../../../testing/utils'; | ||
import { EllipsisText } from './EllipsisText'; | ||
import styles from './EllipsisText.module.css'; | ||
|
||
describe('EllipsisText', () => { | ||
const mockText = `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(EllipsisText, () => { | ||
baselineComponent((props) => <EllipsisText {...props}>EllipsisText</EllipsisText>); | ||
|
||
it('should have specific className when maxLines > 1', async () => { | ||
render( | ||
it('should have specific className when maxLines > 1', () => { | ||
const result = render( | ||
<EllipsisText maxLines={2} data-testid="text-wrapper"> | ||
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. | ||
{mockText} | ||
</EllipsisText>, | ||
); | ||
|
||
const text = screen.getByTestId('text-wrapper').firstElementChild as HTMLElement; | ||
const text = result.getByTestId('text-wrapper').firstElementChild as HTMLElement; | ||
expect(text).not.toBeNull(); | ||
expect(text).toHaveClass(styles.contentMultiline); | ||
}); | ||
|
||
it('should not apply title attribute', () => { | ||
const result = render(<EllipsisText data-testid="host">{mockText}</EllipsisText>); | ||
expect(result.getByTestId('host')).toHaveAttribute('title'); | ||
expect(result.getByTestId('host')).not.toHaveClass(styles.disableNativeTitle); | ||
|
||
result.rerender( | ||
<EllipsisText data-testid="host" disableNativeTitle> | ||
{mockText} | ||
</EllipsisText>, | ||
); | ||
expect(result.getByTestId('host')).not.toHaveAttribute('title'); | ||
expect(result.getByTestId('host')).toHaveClass(styles.disableNativeTitle); | ||
}); | ||
}); |
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