Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

976 B
Raw Blame
import { render, screen } from "@testing-library/react";
import { describe, expect, it } from "vitest";

import { SimpleTable, type SimpleTableColumn } from "./simple_table";

interface Row {
  name: string;
  spend: number;
}

const columns: SimpleTableColumn<Row>[] = [
  { header: "Name", accessor: "name" },
  { header: "Spend", accessor: "spend", numeric: true },
];

describe("SimpleTable numeric columns", () => {
  it("right-aligns the header and cells of a numeric column only", () => {
    render(<SimpleTable data={[{ name: "Alice", spend: 42 }]} columns={columns} />);

    expect(screen.getByRole("columnheader", { name: "Spend" })).toHaveClass("text-right", "tabular-nums");
    expect(screen.getByRole("cell", { name: "42" })).toHaveClass("text-right", "tabular-nums");
    expect(screen.getByRole("columnheader", { name: "Name" })).not.toHaveClass("text-right");
    expect(screen.getByRole("cell", { name: "Alice" })).not.toHaveClass("text-right");
  });
});