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.

1.2 KB
Raw Blame
import { afterEach, describe, expect, it } from "vitest";
import { installPreparedMessage, useCommit } from "../commitStore";
import { installGitLog, useGitLog } from "../logStore";
import { logConsole, useVcsConsole } from "../ops";
import { useVcs } from "../store";

describe("switching the window to another repository", () => {
  const disposers: Array<() => void> = [];
  afterEach(() => disposers.splice(0).forEach((d) => d()));

  it("drops the commit message, Amend and the log of the previous one", () => {
    useVcs.setState({ root: "/a" });
    disposers.push(installPreparedMessage(), installGitLog());
    useCommit.setState({ message: "wip", amend: true, selection: ["/a/x"] });
    useGitLog.setState({ commits: [{ id: "c1" } as never], selected: "c1", selection: ["c1"] });
    useGitLog.setState((s) => ({ filters: { ...s.filters, authors: ["me"] } }));
    logConsole("cmd", "git status");

    useVcs.setState({ root: "/b" });

    expect(useCommit.getState()).toMatchObject({ message: "", amend: false, selection: [] });
    expect(useGitLog.getState()).toMatchObject({ commits: [], selected: null, selection: [] });
    expect(useGitLog.getState().filters.authors).toEqual([]);
    expect(useVcsConsole.getState().lines).toEqual([]);
  });
});