ElectronicBabylonianLiterature/ebl-frontend

View on GitHub
src/common/LinkedImage.test.tsx

Summary

Maintainability
A
0 mins
Test Coverage
import React from 'react'
import { render, screen } from '@testing-library/react'
import LinkedImage from './LinkedImage'

describe('CDLI number provided', () => {
  const url = `https://cdli.mpiwg-berlin.mpg.de/dl/photo/P000000.jpg`
  const alt = 'CDLI photo'

  beforeEach(() => {
    render(<LinkedImage src={url} alt={alt} />)
  })

  it('Displays the image', async () => {
    expect(screen.getByRole('img')).toHaveAttribute('src', url)
  })

  it('Has alt text', async () => {
    expect(screen.getByRole('img')).toHaveAttribute('alt', alt)
  })

  it('Has a link to the image', () => {
    expect(screen.getByRole('link')).toHaveAttribute('href', url)
  })
})