import { describe, it, expect } from 'vitest';
import fs from 'node:fs';
import path from 'node:path';

const cssPath = path.resolve(__dirname, '../../resources/css/tokens.css');
const css = fs.existsSync(cssPath) ? fs.readFileSync(cssPath, 'utf-8') : '';

describe('tokens.css', () => {
    it.each([
        ['--liderra-teal', '#0F6E56'],
        ['--liderra-teal-deep', '#0A5A47'],
        ['--liderra-noir', '#012019'],
        ['--liderra-ivory', '#F6F3EC'],
        ['--liderra-surface', '#FFFFFF'],
        ['--liderra-muted', '#6B6356'],
        ['--liderra-success', '#2E8B57'],
        ['--liderra-saffron', '#D9A441'],
        ['--liderra-error', '#B83A3A'],
        ['--liderra-info', '#3F7C95'],
        ['--liderra-plum', '#7A5BA3'],
        ['--liderra-salmon', '#CC6E50'],
    ])('exposes %s = %s', (name, value) => {
        const re = new RegExp(`${name}\\s*:\\s*${value}`, 'i');
        expect(css).toMatch(re);
    });

    it.each([
        ['--space-1', '4px'],
        ['--space-2', '8px'],
        ['--space-3', '12px'],
        ['--space-4', '16px'],
        ['--space-6', '24px'],
        ['--space-8', '32px'],
        ['--space-12', '48px'],
        ['--space-16', '64px'],
    ])('exposes spacing %s = %s', (name, value) => {
        expect(css).toMatch(new RegExp(`${name}\\s*:\\s*${value}`));
    });

    it.each(['--radius-6', '--radius-8', '--radius-10', '--radius-12', '--radius-14', '--radius-full'])(
        'exposes radius %s',
        (name) => {
            expect(css).toMatch(new RegExp(`${name}\\s*:`));
        },
    );

    it.each(['--shadow-1', '--shadow-2', '--shadow-3', '--shadow-4'])('exposes shadow %s', (name) => {
        expect(css).toMatch(new RegExp(`${name}\\s*:`));
    });

    it('exposes --liderra-line and --liderra-line-strong', () => {
        expect(css).toMatch(/--liderra-line:\s*rgba\(1,\s*32,\s*25,\s*0\.08\)/);
        expect(css).toMatch(/--liderra-line-strong:\s*rgba\(1,\s*32,\s*25,\s*0\.14\)/);
    });
});
