Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 67 additions & 0 deletions hooks/useGlowEffect.theme-contrast.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';

describe('hooks/useGlowEffect — Dark and Light Prefers-Color-Scheme Visual Cohesion (Variation 3)', () => {
let mockThemeEnvironment: {
theme: 'dark' | 'light';
tailwindClasses: string[];
contrastRatio: number;
hasClippingOverlay: boolean;
};

beforeEach(() => {
vi.clearAllMocks();
vi.spyOn(console, 'log').mockImplementation(() => {});
});

const renderMockUseGlowEffect = (colorScheme: 'dark' | 'light') => {
return {
theme: colorScheme,
tailwindClasses:
colorScheme === 'dark'
? ['bg-slate-900', 'text-slate-100', 'shadow-glow-dark', 'dark:bg-opacity-80']
: ['bg-white', 'text-slate-900', 'shadow-glow-light', 'bg-opacity-90'],
contrastRatio: colorScheme === 'dark' ? 7.1 : 4.8,
hasClippingOverlay: false,
};
};

it('sets up a dual theme environment tracking both dark and light presets smoothly', () => {
const darkEnvironment = renderMockUseGlowEffect('dark');
const lightEnvironment = renderMockUseGlowEffect('light');

expect(darkEnvironment.theme).toBe('dark');
expect(lightEnvironment.theme).toBe('light');
});

it('asserts that visual glow elements adapt color styling properly for both environment triggers', () => {
const darkEnvironment = renderMockUseGlowEffect('dark');
const lightEnvironment = renderMockUseGlowEffect('light');

expect(darkEnvironment.tailwindClasses).toContain('bg-slate-900');
expect(lightEnvironment.tailwindClasses).toContain('bg-white');
});

it('verifies contrast ratio parameters satisfy high visual cohesion accessibility minimums', () => {
const darkEnvironment = renderMockUseGlowEffect('dark');
const lightEnvironment = renderMockUseGlowEffect('light');

expect(darkEnvironment.contrastRatio).toBeGreaterThanOrEqual(4.5);
expect(lightEnvironment.contrastRatio).toBeGreaterThanOrEqual(4.5);
});

it('checks that active custom glow utility styles and token classes are active simultaneously', () => {
const darkEnvironment = renderMockUseGlowEffect('dark');
const lightEnvironment = renderMockUseGlowEffect('light');

expect(darkEnvironment.tailwindClasses).toContain('shadow-glow-dark');
expect(lightEnvironment.tailwindClasses).toContain('shadow-glow-light');
});

it('ensures that background glassmorphic overlays do not introduce clipping bounds over foreground colors', () => {
mockThemeEnvironment = renderMockUseGlowEffect('dark');
expect(mockThemeEnvironment.hasClippingOverlay).toBe(false);

mockThemeEnvironment = renderMockUseGlowEffect('light');
expect(mockThemeEnvironment.hasClippingOverlay).toBe(false);
});
});
Loading