Skip to content

Commit

Permalink
2 tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
CarlosUlisesOchoa committed Sep 22, 2023
1 parent 70ef608 commit 2504c72
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import React from 'react'
import { describe, expect, it } from 'vitest'
import { render, screen } from '@testing-library/react'
import BookList from '@/components/BookList/BookList'
import { books } from '@/const/books'

describe('BookList', () => {
it('should render empty list message when no books are available', () => {
const { getByText } = render(<BookList booksArray={[]} />)
expect(
getByText(
/No se han encontrado libros que coincidan con tus criterios de búsqueda./
)
).toBeTruthy()
})

it('should render the books library if data is received', () => {
const { getByText } = render(<BookList booksArray={books} />)
expect(getByText(/El Señor de los Anillos/)).toBeTruthy()
})

// test('renders empty list message when no books are available', () => {
// const { getByText } = render(<BookList booksArray={[]} />)
// expect(
// getByText(/No se han encontrado libros que coincidan con tus criterios de búsqueda./)
// ).toBeInTheDocument()
// })

// test('renders books when available', () => {
// const books = [
// { ISBN: '123', title: 'Book1' },
// { ISBN: '124', title: 'Book2' },
// ]
// const { getByText } = render(<BookList booksArray={books} />)
// expect(getByText('Book1')).toBeInTheDocument()
// expect(getByText('Book2')).toBeInTheDocument()
})
15 changes: 15 additions & 0 deletions pruebas/01-reading-list/CarlosUlisesOchoa/vitest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
import eslint from 'vite-plugin-eslint'
import { resolve } from 'node:path'

export default defineConfig({
test: {
global: true,
environment: 'jsdom',
},
plugins: [react(), eslint()],
resolve: {
alias: [{ find: '@', replacement: resolve(__dirname, './src') }],
},
})

0 comments on commit 2504c72

Please sign in to comment.