import { describe, expect, it, afterEach } from 'vitest';
import { applyGuestTheme } from '../guestTheme';

const baseTheme = {
  primary: '#ff3366',
  secondary: '#ff99aa',
  background: '#111111',
  surface: '#222222',
  mode: 'dark' as const,
};

describe('applyGuestTheme', () => {
  afterEach(() => {
    const root = document.documentElement;
    root.classList.remove('guest-theme', 'dark');
    root.style.removeProperty('color-scheme');
    root.style.removeProperty('--guest-primary');
    root.style.removeProperty('--guest-secondary');
    root.style.removeProperty('--guest-background');
    root.style.removeProperty('--guest-surface');
  });

  it('applies and restores guest theme settings', () => {
    const cleanup = applyGuestTheme(baseTheme);

    expect(document.documentElement.classList.contains('guest-theme')).toBe(true);
    expect(document.documentElement.classList.contains('dark')).toBe(true);
    expect(document.documentElement.style.colorScheme).toBe('dark');
    expect(document.documentElement.style.getPropertyValue('--guest-background')).toBe('#111111');

    cleanup();

    expect(document.documentElement.classList.contains('guest-theme')).toBe(false);
  });
});
