|
1 | 1 | import { debounce, deepEqual, computeTooltipPosition, cssTimeToMs, clearTimeoutRef } from 'utils' |
| 2 | +import { injectStyle } from 'utils/handle-style.ts' |
2 | 3 |
|
3 | 4 | describe('compute positions', () => { |
4 | 5 | test('empty reference elements', async () => { |
@@ -272,3 +273,29 @@ describe('clearTimeoutRef', () => { |
272 | 273 | expect(timeoutRef.current).toBe(null) |
273 | 274 | }) |
274 | 275 | }) |
| 276 | + |
| 277 | +describe('handleStyle', () => { |
| 278 | + test('inject base styles with no CSS into the page', () => { |
| 279 | + injectStyle({ css: null, type: 'base' }) |
| 280 | + |
| 281 | + const styleElement = document.getElementById('react-tooltip-base-styles') |
| 282 | + |
| 283 | + expect(styleElement).toBe(null) |
| 284 | + }) |
| 285 | + |
| 286 | + test('inject core styles into the page', () => { |
| 287 | + injectStyle({ css: `body { background: 'red' }`, type: 'core' }) |
| 288 | + |
| 289 | + const styleElement = document.getElementById('react-tooltip-core-styles') |
| 290 | + |
| 291 | + expect(styleElement.innerHTML).toBe(`body { background: 'red' }`) |
| 292 | + }) |
| 293 | + |
| 294 | + test('inject base styles into the page', () => { |
| 295 | + injectStyle({ css: `body { background: 'red' }`, type: 'base' }) |
| 296 | + |
| 297 | + const styleElement = document.getElementById('react-tooltip-base-styles') |
| 298 | + |
| 299 | + expect(styleElement.innerHTML).toBe(`body { background: 'red' }`) |
| 300 | + }) |
| 301 | +}) |
0 commit comments