Add some more example tests
This commit is contained in:
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user