|
| 1 | +import type { ReactNode } from "react"; |
| 2 | +import { renderToStaticMarkup } from "react-dom/server"; |
| 3 | +import { describe, expect, test, vi } from "vite-plus/test"; |
| 4 | +import { CsvViewerInner } from "./CsvViewer"; |
| 5 | + |
| 6 | +vi.mock("@yaakapp-internal/ui", () => ({ |
| 7 | + Table: ({ children }: { children: ReactNode }) => <table>{children}</table>, |
| 8 | + TableBody: ({ children }: { children: ReactNode }) => <tbody>{children}</tbody>, |
| 9 | + TableCell: ({ children }: { children: ReactNode }) => <td>{children}</td>, |
| 10 | + TableHead: ({ children }: { children: ReactNode }) => <thead>{children}</thead>, |
| 11 | + TableHeaderCell: ({ children }: { children: ReactNode }) => <th>{children}</th>, |
| 12 | + TableRow: ({ children }: { children: ReactNode }) => <tr>{children}</tr>, |
| 13 | +})); |
| 14 | + |
| 15 | +describe("CsvViewer", () => { |
| 16 | + test("renders columns that extend beyond the first row", () => { |
| 17 | + const markup = renderToStaticMarkup( |
| 18 | + <CsvViewerInner |
| 19 | + text={[ |
| 20 | + "startDate,2026-02-03T00:00-03:00", |
| 21 | + "endDate,2026-02-03T23:59:59-03:00", |
| 22 | + "id,Fecha de inicio,Nombre,Estado,Perfil de puesto,ID de sucursal,Sucursal,Fecha de fin,ID de usuario", |
| 23 | + "391118210,2026-02-03 12:58:55,atencion1,Disponible,ATD,3549,sucursal,2026-02-03 12:59:08,42041", |
| 24 | + ].join("\n")} |
| 25 | + />, |
| 26 | + ); |
| 27 | + |
| 28 | + expect(markup).toContain("ID de usuario"); |
| 29 | + expect(markup).toContain("42041"); |
| 30 | + expect(markup.match(/<td>/g)).toHaveLength(20); |
| 31 | + }); |
| 32 | +}); |
0 commit comments