lukaskupczyk/react-hook-consent

View on GitHub
src/core/local-storage/remove.test.ts

Summary

Maintainability
B
6 hrs
Test Coverage
import { removeLocalStorage } from './remove';

describe('removelocalStorage', () => {
    beforeEach(() => {
        localStorage.clear();
    });

    test('should remove all listed items from local storage', () => {
        localStorage.setItem('foo', 'bar');
        localStorage.setItem('baz', 'qux');
        localStorage.setItem('quux', 'quuz');

        removeLocalStorage(['foo', 'baz']);

        expect(localStorage.getItem('foo')).toBeNull();
        expect(localStorage.getItem('baz')).toBeNull();
        expect(localStorage.getItem('quux')).not.toBeNull();
    });
});