-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cutting-off-tooltip): unit test for cutting of tooltip
- Loading branch information
1 parent
adf87fa
commit 6d0e6f7
Showing
1 changed file
with
34 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/components/App/SideBar/AiSummary/AiAnswer/__tests__/index.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,34 @@ | ||
import React from 'react' | ||
import { render, screen, fireEvent, waitFor } from '@testing-library/react' | ||
import { AiAnswer } from '../index' | ||
import { ExtractedEntity } from '~/types/index' | ||
|
||
describe('AiAnswer Component', () => { | ||
const mockHandleLoaded = jest.fn() | ||
|
||
const renderComponent = (answer, entities) => { | ||
render(<AiAnswer answer={answer} entities={entities} handleLoaded={mockHandleLoaded} hasBeenRendered={false} />) | ||
} | ||
|
||
it('should display shows tooltip on hover over entity', async () => { | ||
const entities: ExtractedEntity[] = [ | ||
{ | ||
entity: 'React', | ||
description: 'A JavaScript library for building user interfaces.', | ||
}, | ||
] | ||
|
||
renderComponent('Learn about React and its features.', entities) | ||
|
||
await waitFor(() => expect(screen.getByText(/React/)).toBeInTheDocument()) | ||
|
||
const reactEntity = screen.getByText((content, element) => { | ||
return content.startsWith('React') && element.tagName === 'SPAN' | ||
}) | ||
|
||
fireEvent.mouseOver(reactEntity) | ||
|
||
const tooltip = await screen.findByText('A JavaScript library for building user interfaces.') | ||
expect(tooltip).toBeVisible() | ||
}) | ||
}) |