-
Notifications
You must be signed in to change notification settings - Fork 815
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
70ef608
commit 2504c72
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
pruebas/01-reading-list/CarlosUlisesOchoa/src/components/BookList/__test__/BookList.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
15
pruebas/01-reading-list/CarlosUlisesOchoa/vitest.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') }], | ||
}, | ||
}) |