Initial commit

This commit is contained in:
2025-03-07 19:22:02 +01:00
commit 4a98255d83
55743 changed files with 5280367 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
import { describe, it, vi, expect } from "vitest";
import { renderHook } from "@testing-library/react";
import * as React from "react";
import { useStrictMemo } from "./useStrictMemo";
describe("useStrictMemo", () => {
it("should not call factory twice on mount in strict mode", () => {
const factory = vi.fn();
renderHook(() => useStrictMemo(factory, []), {
wrapper: React.StrictMode,
});
expect(factory).toHaveBeenCalledTimes(1);
});
it("should call factory if dependencies update", () => {
const factory = vi.fn();
let dep = "foo";
const { rerender } = renderHook(() => useStrictMemo(factory, [dep]), {
wrapper: React.StrictMode,
});
dep = "bar";
rerender();
expect(factory).toHaveBeenCalledTimes(2);
});
});