|
| 1 | +import { UniqueProvider } from '@rc-component/trigger'; |
1 | 2 | import { act, fireEvent, render } from '@testing-library/react';
|
2 | 3 | import React from 'react';
|
3 | 4 | import Tooltip, { type TooltipRef } from '../src';
|
@@ -59,8 +60,6 @@ describe('rc-tooltip', () => {
|
59 | 60 | verifyContent(container, 'Tooltip content');
|
60 | 61 | });
|
61 | 62 |
|
62 |
| - |
63 |
| - |
64 | 63 | it('access of ref', () => {
|
65 | 64 | const domRef = React.createRef<TooltipRef>();
|
66 | 65 | render(
|
@@ -353,12 +352,7 @@ describe('rc-tooltip', () => {
|
353 | 352 | };
|
354 | 353 |
|
355 | 354 | const { container } = render(
|
356 |
| - <Tooltip |
357 |
| - styles={customStyles} |
358 |
| - overlay={<div>Tooltip content</div>} |
359 |
| - visible |
360 |
| - showArrow |
361 |
| - > |
| 355 | + <Tooltip styles={customStyles} overlay={<div>Tooltip content</div>} visible showArrow> |
362 | 356 | <button>Trigger</button>
|
363 | 357 | </Tooltip>,
|
364 | 358 | );
|
@@ -439,12 +433,34 @@ describe('rc-tooltip', () => {
|
439 | 433 | // Verify partial configuration takes effect
|
440 | 434 | expect(tooltipElement).toHaveStyle({ backgroundColor: 'blue' });
|
441 | 435 | expect(tooltipBodyElement).toHaveClass('custom-body');
|
442 |
| - |
| 436 | + |
443 | 437 | // Verify that unconfigured elements don't have custom class names or styles
|
444 | 438 | expect(tooltipElement).not.toHaveClass('custom-root');
|
445 | 439 | expect(tooltipArrowElement).not.toHaveClass('custom-arrow');
|
446 | 440 | });
|
447 | 441 |
|
| 442 | + it('should pass uniqueBody to Trigger as uniqueBgClassName and uniqueBgStyle', () => { |
| 443 | + // Test that the component renders without errors when uniqueBody is provided |
| 444 | + render( |
| 445 | + <UniqueProvider> |
| 446 | + <Tooltip |
| 447 | + classNames={{ uniqueBody: 'unique-body-class' }} |
| 448 | + styles={{ uniqueBody: { color: 'red' } }} |
| 449 | + overlay={<div>Tooltip content</div>} |
| 450 | + visible |
| 451 | + unique |
| 452 | + > |
| 453 | + <button>Trigger</button> |
| 454 | + </Tooltip> |
| 455 | + </UniqueProvider>, |
| 456 | + ); |
| 457 | + |
| 458 | + // Test that uniqueBody doesn't break the normal tooltip functionality |
| 459 | + expect(document.querySelector('.unique-body-class')).toHaveStyle({ |
| 460 | + color: 'red', |
| 461 | + }); |
| 462 | + }); |
| 463 | + |
448 | 464 | it('should not break when showArrow is false', () => {
|
449 | 465 | const customClassNames = {
|
450 | 466 | root: 'custom-root',
|
@@ -476,7 +492,7 @@ describe('rc-tooltip', () => {
|
476 | 492 |
|
477 | 493 | // Verify when arrow is not shown
|
478 | 494 | expect(tooltipArrowElement).toBeFalsy();
|
479 |
| - |
| 495 | + |
480 | 496 | // Other styles still take effect
|
481 | 497 | expect(tooltipElement).toHaveClass('custom-root');
|
482 | 498 | expect(tooltipElement).toHaveStyle({ backgroundColor: 'blue' });
|
|
0 commit comments