import { render } from '@testing-library/react'; import SplitText from './SplitText'; // Mock IntersectionObserver class MockIntersectionObserver { observe = jest.fn(); unobserve = jest.fn(); disconnect = jest.fn(); } Object.defineProperty(window, 'IntersectionObserver', { writable: true, configurable: true, value: MockIntersectionObserver, }); describe('SplitText', () => { it('renders emojis correctly', () => { const emojis = ['🚧', '❤️‍🔥', '💜', '🦎', '❌', '✅', '⚠️']; const originalText = emojis.join(''); const { container } = render(); const textSpans = container.querySelectorAll('p > span > span.inline-block'); // Reconstruct the text by joining all span contents const reconstructedText = Array.from(textSpans) .map((span) => span.textContent) .join('') .trim(); // Compare the reconstructed text with the original expect(reconstructedText).toBe(originalText); // Check the first character specifically as the reconstructed text could hide issues for (let i = 0; i < emojis.length; i++) { expect(Array.from(textSpans)[i].textContent).toBe(emojis[i]); } }); });