import { buildAreaPayload, validateAreaForm } from '@/views/sense/area/areaPayload' describe('Sense area payload', () => { it('keeps the optimistic version and normalized geometry', () => { const form = { name: ' 东门警戒线 ', kind: 'direction_line', routeId: 'device-1:main', points: [{ x: '0.2', y: '0.5' }, { x: '0.8', y: '0.5' }], direction: 'reverse', enabled: true, version: 4 } expect(validateAreaForm(form)).toBe('') expect(buildAreaPayload(form)).toEqual({ name: '东门警戒线', kind: 'direction_line', routeId: 'device-1:main', points: [{ x: 0.2, y: 0.5 }, { x: 0.8, y: 0.5 }], direction: 'reverse', enabled: true, expectedVersion: 4 }) }) it('rejects incomplete geometry before sending', () => { expect(validateAreaForm({ name: '危险区域', kind: 'polygon', routeId: 'route-1', points: [] })).toContain('3 到 64') }) })