lukaskupczyk/react-hook-consent

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

Summary

Maintainability
A
0 mins
Test Coverage
import { localStorageKey } from '../../config';
import { saveToLocalStorage } from './save';

test('saveToLocalStorage', () => {
    const consent = ['1', '2', '3'];
    const hash = 'abc123';
    saveToLocalStorage(consent, hash);

    const item = localStorage.getItem(`${localStorageKey}`);

    if (!item) {
        return;
    }

    const storedData = JSON.parse(item);

    expect({ consent: storedData.consent, hash: storedData.hash }).toEqual({ consent, hash });
});