add unit tests
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2026-02-24 11:14:24 +01:00
parent 7e938138ff
commit d7e144620e
23 changed files with 2766 additions and 17 deletions

View File

@@ -0,0 +1,36 @@
import { act } from 'react';
import { createRoot } from 'react-dom/client';
export function renderHook<T>(useHook: () => T) {
let currentValue: T;
function TestComponent() {
currentValue = useHook();
return null;
}
const container = document.createElement('div');
const root = createRoot(container);
act(() => {
root.render(<TestComponent />);
});
return {
result: {
get current() {
return currentValue;
},
},
rerender() {
act(() => {
root.render(<TestComponent />);
});
},
unmount() {
act(() => {
root.unmount();
});
},
};
}