mirror of
https://gitee.com/newgateway/vtj.git
synced 2026-06-25 14:39:02 +08:00
24 lines
825 B
TypeScript
24 lines
825 B
TypeScript
import { expect, describe, test } from 'vitest';
|
|
import { parseComputed } from '../../../src/parser/composition/computed';
|
|
import { buildSymbolTable } from '../../../src/parser/composition/symbolTable';
|
|
|
|
describe('parseComputed', () => {
|
|
test('should parse computed with function', () => {
|
|
const dsl = {
|
|
id: 'test',
|
|
name: 'Test',
|
|
computed: {
|
|
total: { type: 'JSFunction', value: '() => this.count * 2' }
|
|
}
|
|
} as any;
|
|
const symbols = buildSymbolTable(dsl);
|
|
const result = parseComputed(dsl.computed, symbols);
|
|
expect(result[0]).toBe('const total = computed(() => this.count * 2);');
|
|
});
|
|
|
|
test('should handle empty computed', () => {
|
|
const symbols = buildSymbolTable({ id: 'test', name: 'Test' } as any);
|
|
expect(parseComputed({}, symbols)).toEqual([]);
|
|
});
|
|
});
|