Skip to content

AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents

1.3 KB
Raw Blame
/**
 * @vitest-environment jsdom
 */
import { describe, expect, it } from 'vitest';

import { brandSeed } from '@/lib/brand-seed';

describe('brandSeed', () => {
  it('keeps a preview on the page when the saved branding is applied again, until it is cleared', () => {
    brandSeed.apply({
      primaryColor: '#6e41e2',
      statusColors: { danger: '#b91c1c' },
    });
    expect(variable({ name: '--accent-light-9' })).toBe('#6e41e2');
    expect(variable({ name: '--danger-light-9' })).toBe('#b91c1c');

    brandSeed.setPreview({
      primaryColor: '#0ea5e9',
      statusColors: { warning: '#eab308' },
    });
    brandSeed.apply({
      primaryColor: '#16a34a',
      statusColors: { danger: '#991b1b' },
    });
    expect(variable({ name: '--accent-light-9' })).toBe('#0ea5e9');
    expect(variable({ name: '--warning-light-9' })).toBe('#eab308');
    expect(variable({ name: '--danger-light-9' })).toBe('');

    brandSeed.clearPreview();
    expect(variable({ name: '--accent-light-9' })).toBe('#16a34a');
    expect(variable({ name: '--danger-light-9' })).toBe('#991b1b');
    expect(variable({ name: '--warning-light-9' })).toBe('');
  });
});

function variable({ name }: { name: string }): string {
  return document.documentElement.style.getPropertyValue(name);
}