Skip to content
Snippets Groups Projects
Unverified Commit 3ebf8fcf authored by Gustavo Saiani's avatar Gustavo Saiani Committed by GitHub
Browse files

Unit test DataSelectorTablePicker (#25245)

parent 9cd5a5f8
Branches
Tags
No related merge requests found
......@@ -25,15 +25,15 @@ import type Schema from "metabase-lib/lib/metadata/Schema";
import type Table from "metabase-lib/lib/metadata/Table";
type DataSelectorTablePickerProps = {
hasFiltering: boolean;
hasInitialFocus: boolean;
hasNextStep: boolean;
isLoading: boolean;
minTablesToShowSearch: number;
hasFiltering?: boolean;
hasInitialFocus?: boolean;
hasNextStep?: boolean;
isLoading?: boolean;
minTablesToShowSearch?: number;
schemas: Schema[];
selectedDatabase: Database;
selectedSchema: Schema;
selectedTable: Table;
selectedSchema?: Schema;
selectedTable?: Table;
tables: Table[];
onBack?: () => void;
onChangeTable: (table: Table) => void;
......
import React from "react";
import { render, screen } from "@testing-library/react";
import DataSelectorTablePicker from "./DataSelectorTablePicker";
import { createMockTable } from "metabase-types/api/mocks/table";
import { createMockDatabase } from "metabase-types/api/mocks/database";
import type Table from "metabase-lib/lib/metadata/Table";
const database = createMockDatabase();
const table = createMockTable();
const props = {
schemas: [],
onChangeTable: jest.fn(),
};
describe("DataSelectorTablePicker", () => {
it("when no table is in database", () => {
render(
<DataSelectorTablePicker
{...props}
selectedDatabase={database}
tables={[]}
/>,
);
expect(
screen.getByText("No tables found in this database."),
).toBeInTheDocument();
expect(screen.getByText(database.name)).toBeInTheDocument();
});
it("when tables are passed", () => {
const tableName = "Table Name";
const table = { displayName: () => tableName };
render(
<DataSelectorTablePicker
{...props}
selectedDatabase={database}
tables={[table] as Table[]}
/>,
);
expect(screen.getByText(database.name)).toBeInTheDocument();
expect(screen.getByText(tableName)).toBeInTheDocument();
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment