Files
RenewCMS/web/src/lib/__tests__/schemaBuilderTouch.spec.ts
T

19 lines
688 B
TypeScript

import { describe, expect, it } from 'vitest'
import { FIELD_ERROR_TOUCH, fieldTouchKey, typeTouchKey } from '@/lib/schemaBuilderTouch'
describe('touch keys', () => {
it('keeps type and field keys apart', () => {
expect(typeTouchKey('key')).toBe('type:key')
expect(fieldTouchKey(3, 'key')).toBe('field:3:key')
expect(fieldTouchKey(3, 'key')).not.toBe(fieldTouchKey(33, 'key'))
expect(fieldTouchKey(1, 'label')).not.toBe(fieldTouchKey(1, 'key'))
})
it('maps both choice errors to the choices touch', () => {
const choices = FIELD_ERROR_TOUCH.filter(([, touch]) => touch === 'choices').map(
([error]) => error,
)
expect(choices).toEqual(['options', 'choices'])
})
})