import { describe, it, expect } from 'vitest' import { findViolations, ROUND_ALLOWED } from '../../scripts/check-design-gates.mjs' const rules = (src: string, file = 'components/x.tsx'): string[] => (findViolations(src, file) as Array<{ rule: string }>).map(v => v.rule) describe('design gates', () => { it('flags rounded corner classes', () => { expect(rules('
')).toContain('no-rounded') expect(rules('
')).toContain('no-rounded') }) it('flags rounded-full outside the allowlist and accepts it inside', () => { expect(rules('
')).toContain('no-rounded-full') expect(rules('
', ROUND_ALLOWED[0])).not.toContain('no-rounded-full') }) it('flags off-palette colors but accepts remapped gray, blue and red', () => { expect(rules('

')).toContain('off-palette') expect(rules('

')).toContain('off-palette') expect(rules('

')).toEqual([]) }) it('flags hard-coded hex colors', () => { expect(rules('

')).toContain('no-hex') expect(rules('

'quoted'

')).not.toContain('no-hex') }) it('flags centered button labels', () => { expect(rules('')).toContain('no-centered-button') }) it('flags leftovers the codemod should have replaced', () => { expect(rules('
')).toEqual(expect.arrayContaining(['no-bg-white', 'no-heavy-shadow'])) }) it('reports file and 1-based line numbers', () => { const v = findViolations('a\n
', 'components/y.tsx') expect(v[0]).toMatchObject({ file: 'components/y.tsx', line: 2, rule: 'no-rounded' }) }) it('accepts clean on-system markup', () => { expect(rules('
')).toEqual([]) }) })