Skip to content

Commit a6cb2d0

Browse files
committed
✅ Add more tests
1 parent 6bfa823 commit a6cb2d0

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/plugins/expressions/common/expression_functions/specs/tests/map_column.test.ts

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ describe('mapColumn', () => {
9393
{
9494
id: 'myId',
9595
name: 'myName',
96-
meta: { type: 'date' },
96+
meta: { type: 'date', params: { type: 'date', digits: 2 } },
9797
},
9898
],
9999
rows: testTable.rows.map((row) => ({ ...row, myId: Date.now() })),
@@ -105,7 +105,7 @@ describe('mapColumn', () => {
105105
expect(result.columns[nameColumnIndex]).toEqual({
106106
id: 'name',
107107
name: 'name',
108-
meta: { type: 'date' },
108+
meta: { type: 'date', params: { type: 'date', digits: 2 } },
109109
});
110110
});
111111
});
@@ -122,6 +122,19 @@ describe('mapColumn', () => {
122122
);
123123
});
124124

125+
it('should correctly infer the type fromt he first row if the references column for meta information does not exists', () => {
126+
return runFn(
127+
{ ...emptyTable, rows: [...emptyTable.rows, { value: 5 }] },
128+
{ name: 'value', copyMetaFrom: 'time', expression: pricePlusTwo }
129+
).then((result) => {
130+
expect(result.type).toBe('datatable');
131+
expect(result.columns).toHaveLength(1);
132+
expect(result.columns[0]).toHaveProperty('name', 'value');
133+
expect(result.columns[0]).toHaveProperty('id', 'value');
134+
expect(result.columns[0].meta).toHaveProperty('type', 'number');
135+
});
136+
});
137+
125138
describe('expression', () => {
126139
it('maps null values to the new column', () => {
127140
return runFn(testTable, { name: 'empty' }).then((result) => {

0 commit comments

Comments
 (0)