mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-15 18:58:11 +00:00
85 lines
1.7 KiB
TypeScript
85 lines
1.7 KiB
TypeScript
import '../fixtures/window';
|
|
import { deepValueParser } from '../../src/deep-value-parser';
|
|
import { editor } from '../../src/reducers';
|
|
|
|
describe('deepValueParser 测试', () => {
|
|
it('null & undefined', () => {
|
|
expect(deepValueParser()).toBeNull;
|
|
expect(deepValueParser()).toBeUndefined;
|
|
});
|
|
|
|
it('designMode: design', () => {
|
|
expect(deepValueParser({
|
|
a: {
|
|
type: 'variable',
|
|
variable: 'state.a',
|
|
value: '111',
|
|
},
|
|
b: {
|
|
type: 'JSExpression',
|
|
value: 'state.b',
|
|
mock: '222',
|
|
},
|
|
c: {
|
|
type: 'i18n',
|
|
use: 'zh_CN',
|
|
zh_CN: '中文',
|
|
en_US: 'eng',
|
|
},
|
|
slot: {
|
|
type: 'JSSlot',
|
|
value: [{
|
|
componentName: 'Div',
|
|
props: {},
|
|
}],
|
|
},
|
|
arr: [
|
|
{
|
|
type: 'variable',
|
|
variable: 'state.a',
|
|
value: '111',
|
|
},
|
|
{
|
|
type: 'variable',
|
|
variable: 'state.b',
|
|
value: '111',
|
|
},
|
|
],
|
|
})).toMatchSnapshot();
|
|
});
|
|
|
|
it('designMode: live', () => {
|
|
editor.set('designMode', 'live');
|
|
expect(deepValueParser({
|
|
a: {
|
|
type: 'variable',
|
|
variable: 'state.a',
|
|
value: '111',
|
|
},
|
|
b: {
|
|
type: 'JSExpression',
|
|
value: 'state.b',
|
|
mock: '222',
|
|
},
|
|
c: {
|
|
type: 'i18n',
|
|
use: 'zh_CN',
|
|
zh_CN: '中文',
|
|
en_US: 'eng',
|
|
},
|
|
arr: [
|
|
{
|
|
type: 'variable',
|
|
variable: 'state.a',
|
|
value: '111',
|
|
},
|
|
{
|
|
type: 'variable',
|
|
variable: 'state.b',
|
|
value: '111',
|
|
},
|
|
],
|
|
})).toMatchSnapshot();
|
|
});
|
|
});
|