Skip to content
Source
Sign inSign up
Open History to see the last commit

use-vcs-action-state.test.ts

24 lines849 Bytes

1import { describe, expect, it, vi } from "vite-plus/test";
2​
3const mocks = vi.hoisted(() => ({
4 notificationAsync: vi.fn(() => Promise.resolve()),
5}));
6​
7vi.mock("expo-haptics", () => ({
8 NotificationFeedbackType: { Success: "success", Error: "error" },
9 notificationAsync: mocks.notificationAsync,
10}));
11​
12vi.mock("./vcs", () => ({ vcsActionManager: {} }));
13​
14import { dismissGitActionResult, showGitActionResult } from "./use-vcs-action-state";
15​
16describe("showGitActionResult", () => {
17 it("buzzes once per reported result with the matching feedback type", () => {
18 showGitActionResult({ type: "success", title: "Pushed" });
19 showGitActionResult({ type: "error", title: "Git action failed", description: "rejected" });
20 dismissGitActionResult();
21​
22 expect(mocks.notificationAsync.mock.calls).toEqual([["success"], ["error"]]);
23 });
24});