mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 08:53:13 +00:00
fix(settings): typing in the wanderer address and key fields no longer gets undone
useToast handed back a new object on every render. useWandererConnection lists toast in its load effect, so each keystroke reloaded the saved settings and reset both fields to them.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import { render, screen, act } from '../../../tests/helpers/render';
|
||||
import userEvent from '@testing-library/user-event';
|
||||
import { ToastContainer } from './Toast';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { ToastContainer, useToast } from './Toast';
|
||||
|
||||
describe('ToastContainer', () => {
|
||||
beforeEach(() => {
|
||||
@@ -92,3 +93,12 @@ describe('ToastContainer', () => {
|
||||
expect(screen.getByText('Third toast')).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
describe('useToast', () => {
|
||||
it('hands back the same object on every render, so effects that list it do not re-run', () => {
|
||||
const { result, rerender } = renderHook(() => useToast());
|
||||
const first = result.current;
|
||||
rerender();
|
||||
expect(result.current).toBe(first);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user