import { describe, expect, it } from 'vitest' import { conditions, execStatus, publishStatus } from '../../../hooks/option' describe('hooks/option', () => { it('publishStatus 包含关键发布状态且结构正确', () => { expect(publishStatus).toMatchObject({ SAVED: { type: 'info', text: 'publishStatus_SAVED', color: '#909399' }, ONLINE: { type: 'success', text: 'publishStatus_ONLINE', color: '#67C23A' }, OFFLINE_PENDING: { type: 'warning', text: 'publishStatus_OFFLINE_PENDING', color: '#E6A23C' } }) expect(Object.keys(publishStatus)).toHaveLength(7) }) it('execStatus 关键状态的 code text type 与定义一致', () => { expect(execStatus.RUNNING).toEqual({ type: '', text: 'execStatus_RUNNING', code: 'RUNNING' }) expect(execStatus.SUCCEEDED).toEqual({ type: 'success', text: 'execStatus_SUCCEEDED', code: 'SUCCEEDED' }) expect(execStatus.FAILED).toEqual({ type: 'danger', text: 'execStatus_FAILED', code: 'FAILED' }) expect(execStatus.UNKNOWN).toEqual({ type: 'info', text: 'execStatus_UNKNOWN', code: 'UNKNOWN' }) }) it('conditions 关键条件项的 label oper support 正确', () => { expect(conditions.EQUAL).toEqual({ label: 'conditions_EQUAL_label', oper: '=', support: ['string', 'number', 'enum'] }) expect(conditions.NOT_EQUAL).toEqual({ label: 'conditions_NOT_EQUAL_label', oper: '<>', support: ['string', 'number', 'enum'] }) expect(conditions.IN).toEqual({ label: 'conditions_IN_label', oper: 'IN', support: ['enum'] }) }) it('conditions 中的代表性约束配置正确', () => { expect(conditions.LIKE).toMatchObject({ label: 'conditions_LIKE_label', alias: 'conditions_LIKE_alias', oper: 'LIKE', support: ['string'] }) expect(conditions.BETWEEN.support).toEqual(['date', 'number']) expect(conditions.NOT_BETWEEN.support).toEqual(['date', 'number']) expect(conditions.IS_NULL).toEqual({ label: 'conditions_IS_NULL_label', oper: 'IS NULL', support: [] }) expect(conditions.NOT_NULL).toEqual({ label: 'conditions_NOT_NULL_label', oper: 'IS NOT NULL', support: [] }) }) })