tmagic-editor/packages/form/tests/unit/utils/actionButton.spec.ts
roymondchen cbd0442ffc feat(form): 支持 table/group-list 行操作按钮文案与 props 配置
通过 ActionButtonConfig 统一 delete/copy/move/operate 等按钮的 text 与 props,并补充对应单测。
2026-10-19 17:08:02 +08:00

22 lines
811 B
TypeScript

/*
* Tencent is pleased to support the open source community by making TMagicEditor available.
*
* Copyright (C) 2025 Tencent.
*/
import { describe, expect, test } from 'vitest';
import { actionButtonText, DEFAULT_ACTION_BUTTON_TEXT } from '@form/utils/actionButton';
describe('actionButtonText', () => {
test('未配置时返回内置文案', () => {
expect(actionButtonText(undefined, 'operate')).toBe(DEFAULT_ACTION_BUTTON_TEXT.operate);
expect(actionButtonText({}, 'delete')).toBe('删除');
});
test('text 覆盖内置文案,空字符串回退', () => {
expect(actionButtonText({ text: '克隆' }, 'copy')).toBe('克隆');
expect(actionButtonText({ text: '' }, 'moveUp')).toBe('上移');
expect(actionButtonText({ text: '前移' }, 'moveDown')).toBe('前移');
});
});