"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var react_hooks_1 = require("@testing-library/react-hooks"); var index_1 = require("../index"); describe('Hooks operations.', function () { test('useGetCookies should return all cookies.', function () { var result = (0, react_hooks_1.renderHook)(function () { return (0, index_1.useGetCookies)(); }).result; (0, index_1.setCookie)('key1', 'value1'); (0, index_1.setCookie)('key2', 'value2'); var getCookies = result.current; var cookies = null; (0, react_hooks_1.act)(function () { cookies = getCookies(); }); expect(cookies).toEqual({ key1: 'value1', key2: 'value2' }); }); test('useSetCookie should set a cookie', function () { var result = (0, react_hooks_1.renderHook)(function () { return (0, index_1.useSetCookie)(); }).result; var setCookie = result.current; (0, react_hooks_1.act)(function () { setCookie('testKey', 'testValue'); }); expect(document.cookie).toContain('testKey=testValue'); }); test('useDeleteCookie should remove a cookie', function () { var result = (0, react_hooks_1.renderHook)(function () { return (0, index_1.useDeleteCookie)(); }).result; var deleteCookie = result.current; document.cookie = 'testKey3=testValue3'; (0, react_hooks_1.act)(function () { deleteCookie('testKey3'); }); expect(document.cookie).not.toContain('testKey3=testValue3'); }); test('useHasCookie should return true for existing cookie', function () { var result = (0, react_hooks_1.renderHook)(function () { return (0, index_1.useHasCookie)(); }).result; var hasCookie = result.current; document.cookie = 'testKey4=testValue4'; var exists = null; (0, react_hooks_1.act)(function () { exists = hasCookie('testKey4'); }); expect(exists).toBe(true); }); test('useHasCookie should return false for non-existing cookie', function () { var result = (0, react_hooks_1.renderHook)(function () { return (0, index_1.useHasCookie)(); }).result; var hasCookie = result.current; var exists = null; (0, react_hooks_1.act)(function () { exists = hasCookie('nonExistentKey5'); }); expect(exists).toBe(false); }); test('useGetCookie should return undefined for non-existing cookie', function () { var result = (0, react_hooks_1.renderHook)(function () { return (0, index_1.useGetCookie)(); }).result; var getCookie = result.current; var value = null; (0, react_hooks_1.act)(function () { value = getCookie('nonExistentKey'); }); expect(value).toBeUndefined(); }); test('useSetCookie should handle complex values', function () { var complexValue = { key: 'value', nested: { array: [1, 2, 3] } }; var result = (0, react_hooks_1.renderHook)(function () { return (0, index_1.useSetCookie)(); }).result; var setCookie = result.current; (0, react_hooks_1.act)(function () { setCookie('complexKey', complexValue); }); var retrievedValue = (0, index_1.getCookie)('complexKey'); expect(typeof retrievedValue === 'string' ? JSON.parse(retrievedValue) : {}).toEqual(complexValue); }); });