Skip to content

Commit

Permalink
fix(cutting-off-tooltip): unit test for cutting of tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
MahtabBukhari committed Oct 9, 2024
1 parent adf87fa commit 6d0e6f7
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/components/App/SideBar/AiSummary/AiAnswer/__tests__/index.tsx
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) => {

Check failure on line 25 in src/components/App/SideBar/AiSummary/AiAnswer/__tests__/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
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()

Check failure on line 32 in src/components/App/SideBar/AiSummary/AiAnswer/__tests__/index.tsx

View workflow job for this annotation

GitHub Actions / eslint-run

Expected blank line before this statement
})
})

0 comments on commit 6d0e6f7

Please sign in to comment.