|
1 | 1 | import { debounce, deepEqual, computeTooltipPosition, cssTimeToMs } from 'utils' |
| 2 | +import { injectStyle } from 'utils/handle-style.ts' |
2 | 3 |
|
3 | 4 | describe('compute positions', () => { |
4 | 5 | test('empty reference elements', async () => { |
@@ -256,3 +257,29 @@ describe('deepEqual', () => { |
256 | 257 | expect(deepEqual(obj1, obj2)).toBe(false) |
257 | 258 | }) |
258 | 259 | }) |
| 260 | + |
| 261 | +describe('handleStyle', () => { |
| 262 | + test('inject base styles with no CSS into the page', () => { |
| 263 | + injectStyle({ css: null, type: 'base' }) |
| 264 | + |
| 265 | + const styleElement = document.getElementById('react-tooltip-base-styles') |
| 266 | + |
| 267 | + expect(styleElement).toBe(null) |
| 268 | + }) |
| 269 | + |
| 270 | + test('inject core styles into the page', () => { |
| 271 | + injectStyle({ css: `body { background: 'red' }`, type: 'core' }) |
| 272 | + |
| 273 | + const styleElement = document.getElementById('react-tooltip-core-styles') |
| 274 | + |
| 275 | + expect(styleElement.innerHTML).toBe(`body { background: 'red' }`) |
| 276 | + }) |
| 277 | + |
| 278 | + test('inject base styles into the page', () => { |
| 279 | + injectStyle({ css: `body { background: 'red' }`, type: 'base' }) |
| 280 | + |
| 281 | + const styleElement = document.getElementById('react-tooltip-base-styles') |
| 282 | + |
| 283 | + expect(styleElement.innerHTML).toBe(`body { background: 'red' }`) |
| 284 | + }) |
| 285 | +}) |
0 commit comments