import { describe, expect, it } from 'vitest';
import { tableCellTypeDefinition as vueDefinition } from '@kview/ui-data/vue/table-cell-types';
import { tableCellTypeDefinition as bladeDefinition } from '@kview/ui-data/js/table-cell-types';

// Both table engines must render a given cell type identically. This test
// exists specifically to prevent the two registries from silently diverging
// again now that they share one canonical alignment/numeric/nowrap module
// (table-cell-type-definitions.js) instead of duplicating the values.
const TYPES = [
    'text', 'entity', 'link', 'status', 'date', 'amount', 'currency', 'number',
    'scaled-number', 'percentage', 'multiple', 'boolean', 'tag', 'multiselect',
    'quarter', 'year', 'label', 'sparkline',
    // legacy aliases
    'checkbox', 'percent', 'scaled_number',
];

describe('cell-type definition parity (Blade vs Vue engine)', () => {
    it.each(TYPES)('renders "%s" with the same alignment/numeric/nowrap in both engines', (type) => {
        const vue = vueDefinition(type as never);
        const blade = bladeDefinition(type);

        expect(vue.alignment).toBe(blade.alignment);
        expect(vue.numeric).toBe(blade.numeric);
        expect(vue.nowrap).toBe(blade.nowrap);
    });

    it('falls back to "text" for an unknown type in both engines', () => {
        const vue = vueDefinition('not-a-real-type' as never);
        const blade = bladeDefinition('not-a-real-type');
        const text = vueDefinition('text');

        expect(vue).toEqual(text);
        expect(blade.alignment).toBe(text.alignment);
        expect(blade.numeric).toBe(text.numeric);
        expect(blade.nowrap).toBe(text.nowrap);
    });
});
