mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-05-02 11:33:05 +02:00
32 lines
956 B
TypeScript
32 lines
956 B
TypeScript
import { act, renderHook } from '@testing-library/react';
|
|
import { beforeEach, describe, expect, it } from 'vitest';
|
|
|
|
import { useRememberedServerPassword } from '../hooks/useRememberedServerPassword';
|
|
|
|
describe('useRememberedServerPassword', () => {
|
|
beforeEach(() => {
|
|
localStorage.clear();
|
|
});
|
|
|
|
it('restores the last in-memory password when local remember is disabled', () => {
|
|
const { result, unmount } = renderHook(() =>
|
|
useRememberedServerPassword('room', 'aa'.repeat(32))
|
|
);
|
|
|
|
act(() => {
|
|
result.current.setPassword('room-secret');
|
|
result.current.persistAfterLogin('room-secret');
|
|
});
|
|
|
|
expect(result.current.password).toBe('room-secret');
|
|
unmount();
|
|
|
|
const { result: remounted } = renderHook(() =>
|
|
useRememberedServerPassword('room', 'aa'.repeat(32))
|
|
);
|
|
|
|
expect(remounted.current.password).toBe('room-secret');
|
|
expect(remounted.current.rememberPassword).toBe(false);
|
|
});
|
|
});
|