Skip to content

The IDE you know, rebuilt in Rust. IntelliJ IDEA–style keymap, tool windows and search-everywhere in a fast native app: editor, code insight, debugger, Git, terminal, database and HTTP clients for 60+ languages.

628 B
Raw Blame
import { describe, expect, it } from "vitest";
import { filterColumns } from "./ColumnsPopup";

const columns = ["id", "user_id", "name", "created_at", "username"].map((name) => ({ name, type: "TEXT" }));

describe("filterColumns", () => {
  it("lists every column for an empty query", () => {
    expect(filterColumns(columns, " ")).toEqual([0, 1, 2, 3, 4]);
  });

  it("puts prefix matches first, then other matches, ignoring case", () => {
    expect(filterColumns(columns, "US")).toEqual([1, 4]);
    expect(filterColumns(columns, "name")).toEqual([2, 4]);
    expect(filterColumns(columns, "_id")).toEqual([1]);
  });
});