feat: 参考建议可选值最多展示个数由 5 调整为 20

This commit is contained in:
roymondchen 2026-07-23 22:07:51 +08:00
parent d0a22315c0
commit 0e1986c819
3 changed files with 6 additions and 5 deletions

View File

@ -58,7 +58,7 @@ const stringifyExampleValue = (value: any): string => {
};
// 参考建议中最多展示的可选值个数,超出以「等」省略。
const MAX_SUGGESTION_OPTIONS = 5;
const MAX_SUGGESTION_OPTIONS = 20;
/**
* 使xxxxxx

View File

@ -142,7 +142,7 @@ const stringifyExampleValue = (value: any): string => {
};
// 参考建议中最多展示的可选值个数,超出以「等」省略。
const MAX_SUGGESTION_OPTIONS = 5;
const MAX_SUGGESTION_OPTIONS = 20;
/**
* 使xxxxxx

View File

@ -196,13 +196,14 @@ describe('validateTypeMatch', () => {
expect(validateTypeMatch(3, mForm, propsOf(config))).toBe('3 不在可选项中\n\n请使用以下某一个值12');
});
test('可选项超过 5 个时建议仅展示前 5 个并以「等」省略', () => {
test('可选项超过 20 个时建议仅展示前 20 个并以「等」省略', () => {
const values = Array.from({ length: 21 }, (_, i) => i + 1);
const config = {
type: 'select',
options: [1, 2, 3, 4, 5, 6, 7].map((v) => ({ text: `${v}`, value: v })),
options: values.map((v) => ({ text: `${v}`, value: v })),
};
expect(validateTypeMatch(99, mForm, propsOf(config))).toBe(
'99 不在可选项中\n\n请使用以下某一个值12345 等',
`99 不在可选项中\n\n请使用以下某一个值${values.slice(0, 20).join('')}`,
);
});