import {describe, it, expect} from 'vitest' import {render, screen} from '@testing-library/react' import Komante from '../komante' describe('Komante', () => { it('ne rend rien quand il n\'y a aucun commentaire', () => { const {container} = render() expect(container).toBeEmptyDOMElement() }) it('affiche un commentaire local avec le pseudo pawol.nu', () => { render() expect(screen.getByText('foo')).toBeInTheDocument() expect(screen.getByText('Bèl tèks')).toBeInTheDocument() expect(screen.queryByText('Mastodon')).not.toBeInTheDocument() }) it('affiche un commentaire fédéré avec le badge et le lien Mastodon', () => { render() expect(screen.getByText('Quelqu\'un')).toBeInTheDocument() expect(screen.getByText('Mastodon')).toBeInTheDocument() expect(screen.getByRole('link', {name: 'Quelqu\'un'})).toHaveAttribute('href', 'https://mastodon.social/@quelqun') expect(screen.getByRole('link', {name: /voir sur mastodon/i})).toHaveAttribute('href', 'https://bokante.o-k-i.net/@quelqun/1') }) it('met en valeur les mentions @ dans le contenu', () => { render() const mansyon = screen.getByText('@pawol_nu') expect(mansyon).toBeInTheDocument() expect(screen.getByText('@cybermawonaj@bokante.o-k-i.net')).toBeInTheDocument() expect(screen.getByText(/oh oh ye ye/)).toBeInTheDocument() }) })