import sharp from 'sharp';
import fs from 'fs';
import path from 'path';
import { describe, test, expect } from 'vitest';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

describe('PWA Icon Generation - favicon.png', () => {
	const faviconPath = path.join(__dirname, '..', '..', 'static', 'favicon.png');

	test('favicon.png should exist', () => {
		expect(fs.existsSync(faviconPath)).toBe(true);
	});

	test('favicon.png should have exact 192x192 dimensions', async () => {
		const metadata = await sharp(faviconPath).metadata();
		expect(metadata.width).toBe(192);
		expect(metadata.height).toBe(192);
	});

	test('favicon.png should be PNG format', async () => {
		const metadata = await sharp(faviconPath).metadata();
		expect(metadata.format).toBe('png');
	});

	test('favicon.png should be less than 100KB', () => {
		const stats = fs.statSync(faviconPath);
		expect(stats.size).toBeLessThan(100 * 1024);
	});

	test('favicon.png should have RGBA channels', async () => {
		const metadata = await sharp(faviconPath).metadata();
		expect(metadata.channels).toBe(4); // RGBA
	});
});
