diff --git a/pruebas/01-reading-list/CarlosUlisesOchoa/src/components/BookList/__test__/BookList.test.jsx b/pruebas/01-reading-list/CarlosUlisesOchoa/src/components/BookList/__test__/BookList.test.jsx new file mode 100644 index 000000000..7307d1f75 --- /dev/null +++ b/pruebas/01-reading-list/CarlosUlisesOchoa/src/components/BookList/__test__/BookList.test.jsx @@ -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() + 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() + expect(getByText(/El Señor de los Anillos/)).toBeTruthy() + }) + + // test('renders empty list message when no books are available', () => { + // const { getByText } = render() + // 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() + // expect(getByText('Book1')).toBeInTheDocument() + // expect(getByText('Book2')).toBeInTheDocument() +}) diff --git a/pruebas/01-reading-list/CarlosUlisesOchoa/vitest.config.js b/pruebas/01-reading-list/CarlosUlisesOchoa/vitest.config.js new file mode 100644 index 000000000..2486c7e79 --- /dev/null +++ b/pruebas/01-reading-list/CarlosUlisesOchoa/vitest.config.js @@ -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') }], + }, +})