fix: isolate EventCard tests and clean compose refs hook
This commit is contained in:
@@ -54,9 +54,12 @@ function composeRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {
|
||||
* A custom hook that composes multiple refs
|
||||
* Accepts callback refs and RefObject(s)
|
||||
*/
|
||||
function useComposedRefs<T>(...refs: PossibleRef<T>[]): React.RefCallback<T> {
|
||||
// biome-ignore lint/correctness/useExhaustiveDependencies: we want to memoize by all values
|
||||
return React.useCallback(composeRefs(...refs), refs);
|
||||
function useComposedRefs<T>(
|
||||
ref1: PossibleRef<T>,
|
||||
ref2: PossibleRef<T>,
|
||||
ref3?: PossibleRef<T>,
|
||||
): React.RefCallback<T> {
|
||||
return React.useMemo(() => composeRefs(ref1, ref2, ref3), [ref1, ref2, ref3]);
|
||||
}
|
||||
|
||||
export { composeRefs, useComposedRefs };
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { describe, expect, test } from "bun:test";
|
||||
import { afterEach, beforeEach, describe, expect, test } from "bun:test";
|
||||
import { renderToStaticMarkup } from "react-dom/server";
|
||||
import { EventCard } from "@/components/event-card";
|
||||
import type { CalendarEvent } from "@/lib/types";
|
||||
@@ -15,6 +15,17 @@ const sampleEvent: CalendarEvent = {
|
||||
};
|
||||
|
||||
describe("EventCard actions trigger", () => {
|
||||
beforeEach(() => {
|
||||
globalThis.document = {
|
||||
addEventListener: () => {},
|
||||
removeEventListener: () => {},
|
||||
} as unknown as Document;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
delete (globalThis as { document?: Document }).document;
|
||||
});
|
||||
|
||||
test("shows the triple-dots trigger without requiring hover and exposes an aria-label for the icon-only button", () => {
|
||||
const markup = renderToStaticMarkup(
|
||||
EventCard({
|
||||
|
||||
Reference in New Issue
Block a user