Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

1.1 KB
Raw Blame
import { applyUiScale, MIN_UI_SCALE, MAX_UI_SCALE, DEFAULT_UI_SCALE } from './theme';

describe('applyUiScale', () => {
  const readScale = () => document.documentElement.style.getPropertyValue('--ui-scale');

  afterEach(() => {
    document.documentElement.style.removeProperty('--ui-scale');
  });

  it('sets the scale custom property on the root element', () => {
    applyUiScale(1.25);
    expect(readScale()).toBe('1.25');
  });

  it('clamps values below the minimum', () => {
    applyUiScale(0.1);
    expect(readScale()).toBe(String(MIN_UI_SCALE));
  });

  it('clamps values above the maximum', () => {
    applyUiScale(4);
    expect(readScale()).toBe(String(MAX_UI_SCALE));
  });

  it('falls back to the default for non-finite values', () => {
    applyUiScale(Number.NaN);
    expect(readScale()).toBe(String(DEFAULT_UI_SCALE));

    applyUiScale(Number.POSITIVE_INFINITY);
    expect(readScale()).toBe(String(DEFAULT_UI_SCALE));
  });

  it('falls back to the default when a persisted value is not a number', () => {
    applyUiScale('1.25' as unknown as number);
    expect(readScale()).toBe(String(DEFAULT_UI_SCALE));
  });
});