Add some more example tests

This commit is contained in:
Steve Kinney
2024-10-01 19:52:06 -05:00
parent 5710f74461
commit 93775a8f02
5 changed files with 51 additions and 6 deletions

View File

@@ -8,6 +8,7 @@ describe('createSecretInput', async () => {
beforeEach(() => {
vi.spyOn(localStorage, 'getItem').mockReturnValue('test secret');
vi.spyOn(localStorage, 'setItem');
vi.spyOn(localStorage, 'removeItem');
document.body.innerHTML = '';
document.body.appendChild(createSecretInput());
@@ -32,4 +33,12 @@ describe('createSecretInput', async () => {
expect(localStorage.setItem).toHaveBeenCalledWith('secret', 'new secret');
});
it('should clear the secret from localStorage', async () => {
const button = screen.getByText('Clear Secret');
await userEvent.click(button);
expect(localStorage.removeItem).toHaveBeenCalledWith('secret');
});
});