navidrome/ui/src/common/Linkify.test.jsx
Deluan Quintão b2019da999
chore(deps): update all dependencies (#4618)
* chore: update to Go 1.25.3

Signed-off-by: Deluan <deluan@navidrome.org>

* chore: update to golangci-lint

Signed-off-by: Deluan <deluan@navidrome.org>

* chore: update go dependencies

Signed-off-by: Deluan <deluan@navidrome.org>

* chore: update vite dependencies in package.json and improve EventSource mock in tests

- Upgraded @vitejs/plugin-react to version 5.1.0 and @vitest/coverage-v8 to version 4.0.3.
- Updated vite to version 7.1.12 and vite-plugin-pwa to version 1.1.0.
- Enhanced the EventSource mock implementation in eventStream.test.js for better test isolation.

* ci: remove coverage flag from Go test command in pipeline

* chore: update Node.js version to v24 in devcontainer, pipeline, and .nvmrc

* chore: prettier

Signed-off-by: Deluan <deluan@navidrome.org>

* chore: update actions/checkout from v4 to v5 in pipeline and update-translations workflows

* chore: update JS dependencies remove unused jest-dom import in Linkify.test.jsx

* chore: update actions/download-artifact from v4 to v5 in pipeline

---------

Signed-off-by: Deluan <deluan@navidrome.org>
2025-10-25 17:05:16 -04:00

34 lines
981 B
JavaScript

import React from 'react'
import { render, screen } from '@testing-library/react'
import Linkify from './Linkify'
const URL = 'http://www.example.com'
const expectLink = (url) => {
const linkEl = screen.getByRole('link')
expect(linkEl).not.toBeNull()
expect(linkEl?.href).toBe(url)
}
describe('<Linkify />', () => {
it('should render link', () => {
render(<Linkify text={URL} />)
expectLink(`${URL}/`)
expect(screen.getByText(URL)).toBeInTheDocument()
})
it('should render link and text', () => {
render(<Linkify text={`foo ${URL} bar`} />)
expectLink(`${URL}/`)
expect(screen.getByText(/foo/i)).toBeInTheDocument()
expect(screen.getByText(URL)).toBeInTheDocument()
expect(screen.getByText(/bar/i)).toBeInTheDocument()
})
it('should render only text', () => {
render(<Linkify text={'foo bar'} />)
expect(screen.queryAllByRole('link')).toHaveLength(0)
expect(screen.getByText(/foo bar/i)).toBeInTheDocument()
})
})