gongxiangp2/lib/__tests__/work-review-annotation-marker.test.tsx

39 lines
1.2 KiB
TypeScript

/** @jest-environment jsdom */
import { render, screen } from '@testing-library/react'
import { WorkReviewAnnotationMarker } from '@/components/work-review/WorkReviewAnnotationMarker'
const longComment = '这画太中古了,细节也过多,抢主体了,需要换成偏现代的画并减少背景元素'
describe('WorkReviewAnnotationMarker', () => {
test.each([
['point', {}],
['rectangle', { x2: 0.7, y2: 0.6, shape: 'rectangle' as const }],
])('wraps the complete %s annotation comment instead of truncating it', (_shape, geometry) => {
render(
<WorkReviewAnnotationMarker
item={{
markerNumber: 1,
annotation: {
id: 'annotation-1',
x: 0.3,
y: 0.3,
comment: longComment,
...geometry,
},
}}
/>,
)
const visibleComment = screen.getByText(longComment)
expect(visibleComment).toHaveClass(
'whitespace-normal',
'break-words',
'max-w-[min(10rem,calc(100vw-3rem))]',
'sm:max-w-[min(14rem,calc(100vw-3rem))]',
'[overflow-wrap:anywhere]',
)
expect(visibleComment).not.toHaveClass('truncate')
})
})