You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
pokedex/test/PokemonList.jest.spec.jsx

29 lines
712 B
JavaScript

import React from 'react'
import { render, screen } from '@testing-library/react'
import { BrowserRouter } from 'react-router-dom'
import '@testing-library/jest-dom/extend-expect'
import PokemonList from '../src/PokemonList'
const pokemonList = [{
url: 'https://pokeapi.co/api/v2/pokemon/1/',
name: 'bulbasaur',
id: 1
}, {
url: 'https://pokeapi.co/api/v2/pokemon/133/',
name: 'eevee',
id: 133
}]
describe('<PokemonList />', () => {
it('should render items', () => {
render(
<BrowserRouter>
<PokemonList pokemonList={pokemonList} />
</BrowserRouter>
)
expect(screen.getByText('bulbasaur')).toBeVisible()
expect(screen.getByText('eevee')).toBeVisible()
})
})