diff --git a/src/__tests__/render-hook.test.tsx b/src/__tests__/render-hook.test.tsx new file mode 100644 index 00000000..e0812694 --- /dev/null +++ b/src/__tests__/render-hook.test.tsx @@ -0,0 +1,18 @@ +import * as React from 'react'; + +import { renderHook } from '..'; + +it('renders a hook with initial props and allows rerendering with new props', async () => { + const useValue = (value: number) => { + return { value }; + }; + + const { result, rerender } = await renderHook(useValue, { + initialProps: 5, + }); + + expect(result.current.value).toBe(5); + + await rerender(10); + expect(result.current.value).toBe(10); +}); diff --git a/test-coverage-progress.txt b/test-coverage-progress.txt index 0997522c..790b7829 100644 --- a/test-coverage-progress.txt +++ b/test-coverage-progress.txt @@ -8,3 +8,4 @@ test(queries/hint-text): Validates getByHintText finds elements by their accessi test(queries/test-id): Validates getByTestId with exact:false option for partial testID matching - critical for testing components with dynamic or prefixed testIDs. Coverage: 96.42% statements (was 89.28%), 83.33% branches, 66.66% functions for test-id.ts. Covered matchTestId function with exact option and queryAllByTestId implementation. Uncovered: error message functions (getMultipleError, getMissingError). test(wait-for): Validates waitFor timeout behavior when expectation never passes - critical error handling users depend on when async conditions fail. Coverage: 55% statements (was 12%), 43.47% branches, 85.71% functions for wait-for.ts. Covered timeout error path and lastError handling. Uncovered: fake timers path, promise-returning expectations, onTimeout callback, timer switching errors. test(wait-for-element-to-be-removed): Validates error when element is already removed at call time - critical error handling users depend on when misusing the API. Coverage: 61.9% statements (was 9.52%), 66.66% branches, 100% functions for wait-for-element-to-be-removed.ts. Covered isRemoved helper and initial validation error path. Uncovered: wait logic (lines 27-42). +test(render-hook): Validates renderHook with initial props and rerender functionality - critical API users depend on for testing React hooks with props. Coverage: 100% statements (was 5.66%), 85.71% branches, 100% functions for render-hook.tsx. Covered hook rendering, initialProps, rerender with new props. Uncovered: line 41 (options destructuring edge case).