/
githubmirror
/
lerna
Обзор
Документация
Войти
/
githubmirror
/
lerna
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
libs/commands/version/src/lib/git-commit.spec.ts
59 строк
2 KB
James Henry
chore(repo): migrate from jest to vitest (#4389)
13 июл 2026, 20:06
Не верифицирован
13 июл 2026, 20:06
1f7e109
Код
Авторство
О чём код?
import { tempWrite as _tempWrite } from "@lerna/core"; import { EOL } from "os"; import { gitCommit } from "./git-commit"; vi.mock("@lerna/child-process"); vi.mock("@lerna/core", async () => ({ tempWrite: { sync: vi.fn(), }, log: (await vi.importActual("@lerna/core")).log, })); const tempWrite = vi.mocked(_tempWrite); import * as childProcess from "@lerna/child-process"; describe("git commit", () => { childProcess.exec.mockResolvedValue(); tempWrite.sync.mockReturnValue("temp-file-path"); test("--message", async () => { const opts = { cwd: "message" }; await gitCommit("subject", {}, opts); expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "-m", "subject"], opts); }); test("--message <multiline>", async () => { const message = `subject${EOL}${EOL}body`; const opts = { cwd: "multi-line" }; await gitCommit(message, {}, opts); expect(tempWrite.sync).toHaveBeenLastCalledWith(message, "lerna-commit.txt"); expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "-F", "temp-file-path"], opts); }); test("--amend", async () => { const opts = { cwd: "no-edit" }; await gitCommit("whoops", { amend: true }, opts); expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "--amend", "--no-edit"], opts); }); test("--no-commit-hooks", async () => { const opts = { cwd: "no-verify" }; await gitCommit("yolo", { commitHooks: false }, opts); expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "--no-verify", "-m", "yolo"], opts); }); test("--sign-git-commit", async () => { const opts = { cwd: "signed" }; await gitCommit("nice", { signGitCommit: true }, opts); expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "--gpg-sign", "-m", "nice"], opts); }); test("--signoff-git-commit", async () => { const opts = { cwd: "signed-off" }; await gitCommit("nice", { signoffGitCommit: true }, opts); expect(childProcess.exec).toHaveBeenLastCalledWith("git", ["commit", "--signoff", "-m", "nice"], opts); }); });