-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
43 additions
and
2 deletions.
There are no files selected for viewing
File renamed without changes.
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,41 @@ | ||
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest' | ||
import { render, screen } from '@testing-library/svelte' | ||
import ProductoRow from './ProductoRow.svelte' | ||
import { Producto } from './productos' | ||
|
||
describe('el producto', () => { | ||
|
||
const producto = new Producto('Manguera Remix', 1200, 4, 2, 'manguera.png') | ||
|
||
beforeEach(() => { | ||
vi.useFakeTimers() | ||
// seteamos una fecha controlada como la fecha de hoy | ||
const date = new Date(2024, 1, 20, 0, 0, 0) | ||
vi.setSystemTime(date) | ||
}) | ||
|
||
afterEach(() => { | ||
vi.useRealTimers() | ||
}) | ||
|
||
it('muestra el elemento seleccionado con una clase especial', () => { | ||
render(ProductoRow, { producto, seleccionado: true }) | ||
expect(screen.getByTestId('row').classList).toContain('elegido') | ||
}) | ||
|
||
it('muestra el elemento no seleccionado con una clase normal', () => { | ||
render(ProductoRow, { producto, seleccionado: false }) | ||
expect(screen.getByTestId('row').classList).toContain('normal') | ||
}) | ||
|
||
it('muestra la fecha de entrega en base a la cantidad de días', () => { | ||
render(ProductoRow, { producto, seleccionado: false }) | ||
expect(screen.getByTestId('fecha-entrega').innerHTML).toBe('Llega el 22/02/2024') | ||
}) | ||
|
||
it('muestra el valor del producto con el formateo de currency', () => { | ||
render(ProductoRow, { producto, seleccionado: false }) | ||
expect(screen.getByTestId('precio').innerHTML).toBe('$ 1.200,00') | ||
}) | ||
|
||
}) |
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
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