amis/packages/amis-core/__tests__/datamapping.test.ts

34 lines
486 B
TypeScript
Raw Normal View History

2022-06-16 12:39:59 +08:00
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}
]
});
});