feat: 优化代码节点 main 编写体验
- 更新代码节点帮助、占位示例与补全片段 - 保留 _result 旧版兼容提示并补充补全测试
This commit is contained in:
@@ -52,6 +52,25 @@ describe('codeCompletion utils', () => {
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
it('should prefer main return snippets for javascript output', () => {
|
||||
const completions = createBusinessCompletions('javascript', []);
|
||||
const mainCompletion = completions.find((item) => item.label === 'main');
|
||||
const resultCompletion = completions.find(
|
||||
(item) => item.label === 'result-object',
|
||||
);
|
||||
|
||||
expect(mainCompletion).toMatchObject({
|
||||
type: 'snippet',
|
||||
detail: '代码节点入口',
|
||||
boost: 1000,
|
||||
});
|
||||
expect(String(mainCompletion?.apply)).toContain('function main');
|
||||
expect(String(mainCompletion?.apply)).toContain('return {');
|
||||
expect(String(resultCompletion?.apply)).toBe(
|
||||
"return { message: 'ok', data };",
|
||||
);
|
||||
});
|
||||
|
||||
it('should detect blocked nodes for comment/string/property contexts', () => {
|
||||
expect(shouldSkipBusinessCompletion('Comment')).toBe(true);
|
||||
expect(shouldSkipBusinessCompletion('LineComment')).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user