mirror of
https://gitee.com/baidu/amis.git
synced 2024-11-29 18:48:45 +08:00
34 lines
486 B
TypeScript
34 lines
486 B
TypeScript
import {dataMapping} from '../src';
|
|
|
|
test('datamapping', async () => {
|
|
const context = {
|
|
a: 1,
|
|
b: 2,
|
|
c: [
|
|
{a: 1, b: 1},
|
|
{a: 2, b: 2}
|
|
]
|
|
};
|
|
|
|
const result = dataMapping(
|
|
{
|
|
a: '${a}',
|
|
b: '${c}',
|
|
c: '${ARRAYMAP(c, item => {a: item.a, c: item.b})}'
|
|
},
|
|
context
|
|
);
|
|
|
|
expect(result).toMatchObject({
|
|
a: 1,
|
|
b: [
|
|
{a: 1, b: 1},
|
|
{a: 2, b: 2}
|
|
],
|
|
c: [
|
|
{a: 1, c: 1},
|
|
{a: 2, c: 2}
|
|
]
|
|
});
|
|
});
|