lumrop/tests/useTitle.test.ts
Tudor Stanciu 75a40aba1f chore: update package version to 1.3.0 and modify dependencies
feat: add copyright notice to hooks and index files

fix: update test imports to use @testing-library/react

refactor: change TypeScript target from es5 to es6

chore: add ESLint configuration for TypeScript and React
2025-04-16 01:35:11 +03:00

26 lines
691 B
TypeScript

// Copyright (c) 2022 Tudor Stanciu
import { renderHook, act } from "@testing-library/react";
import { useTitle } from "../src";
describe("useTitle", () => {
it("should set the document title", () => {
const title = "New Page Title";
renderHook(() => useTitle(title));
expect(document.title).toBe(title);
});
it("should reset the document title when unmounted", () => {
const title = "New Page Title";
const { unmount } = renderHook(() => useTitle(title));
expect(document.title).toBe(title);
act(() => {
unmount();
});
// The document title should now be reset to its previous value
expect(document.title).not.toBe(title);
});
});