# extendify/3.0.5/src/Launch/api/__tests__/getSiteLogo.test.js

Extendify, version 3.0.5. 101 lines.

- Page: https://pluginprobe.com/plugins/extendify/3.0.5/code/src/Launch/api/__tests__/getSiteLogo.test.js
- Raw: https://pluginprobe.com/plugins/extendify/3.0.5/raw/src/Launch/api/__tests__/getSiteLogo.test.js
- Modified: 2026-02-18T22:27:14+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/extendify/3.0.5/code/src/Launch/api/__tests__/getSiteLogo.test.js#L10-L20`.

```javascript
import { getSiteLogo } from '@launch/api/DataApi';

const fallbackUrl =
	'https://images.extendify-cdn.com/demo-content/logos/ext-custom-logo-default.webp';

const originalFetch = global.fetch;

describe('getSiteLogo', () => {
	beforeEach(() => {
		global.fetch = jest.fn();

		window.extSharedData = Object.assign({}, window.extSharedData, {
			siteId: 'test-site',
			partnerId: 'test-partner',
			showAILogo: true,
		});
	});

	afterEach(() => {
		jest.clearAllMocks();
		global.fetch = originalFetch;
	});

	it('returns logoUrl on successful fetch and valid JSON', async () => {
		global.fetch.mockResolvedValueOnce({
			ok: true,
			json: () => ({ logoUrl: 'https://cdn/image.png' }),
		});

		const result = await getSiteLogo('test-logo');
		expect(result).toBe('https://cdn/image.png');
		expect(global.fetch).toHaveBeenCalledTimes(1);
	});

	it('returns fallback when showAILogo is false', async () => {
		global.window.extSharedData = {
			siteId: 'test-site',
			partnerId: 'test-partner',
			showAILogo: false,
		};

		const result = await getSiteLogo('test-logo');
		expect(result).toBe(fallbackUrl);
		expect(global.fetch).not.toHaveBeenCalled();
	});

	it('throws error when required parameters are missing', async () => {
		global.window.extSharedData = {
			siteId: '',
			partnerId: 'test-partner',
			showAILogo: true,
		};

		await expect(getSiteLogo('test-logo')).rejects.toThrow(
			'Missing required parameter (siteId, partnerId or objectName)',
		);
	});

	it('returns fallback on failed fetch and retry (non-ok response)', async () => {
		global.fetch
			.mockRejectedValueOnce(new Error('Network error'))
			.mockResolvedValueOnce({ ok: false });

		const result = await getSiteLogo('test-logo');
		expect(result).toBe(fallbackUrl);
		expect(global.fetch).toHaveBeenCalledTimes(2);
	});

	it('returns fallback on JSON parse error', async () => {
		global.fetch.mockResolvedValueOnce({
			ok: true,
			json: () => {
				throw new Error('Invalid JSON');
			},
		});

		const result = await getSiteLogo('test-logo');
		expect(result).toBe(fallbackUrl);
	});

	describe('returns fallback when objectName is falsy', () => {
		it('returns fallback when objectName is null', async () => {
			const result = await getSiteLogo(null);
			expect(result).toBe(fallbackUrl);
			expect(global.fetch).not.toHaveBeenCalled();
		});

		it('returns fallback when objectName is undefined', async () => {
			const result = await getSiteLogo(undefined);
			expect(result).toBe(fallbackUrl);
			expect(global.fetch).not.toHaveBeenCalled();
		});

		it('returns fallback when objectName is an empty string', async () => {
			const result = await getSiteLogo('');
			expect(result).toBe(fallbackUrl);
			expect(global.fetch).not.toHaveBeenCalled();
		});
	});
});

```
