Skip to content

Commit

Permalink
✅ Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dej611 committed Feb 24, 2021
1 parent 6bfa823 commit a6cb2d0
Showing 1 changed file with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ describe('mapColumn', () => {
{
id: 'myId',
name: 'myName',
meta: { type: 'date' },
meta: { type: 'date', params: { type: 'date', digits: 2 } },
},
],
rows: testTable.rows.map((row) => ({ ...row, myId: Date.now() })),
Expand All @@ -105,7 +105,7 @@ describe('mapColumn', () => {
expect(result.columns[nameColumnIndex]).toEqual({
id: 'name',
name: 'name',
meta: { type: 'date' },
meta: { type: 'date', params: { type: 'date', digits: 2 } },
});
});
});
Expand All @@ -122,6 +122,19 @@ describe('mapColumn', () => {
);
});

it('should correctly infer the type fromt he first row if the references column for meta information does not exists', () => {
return runFn(
{ ...emptyTable, rows: [...emptyTable.rows, { value: 5 }] },
{ name: 'value', copyMetaFrom: 'time', expression: pricePlusTwo }
).then((result) => {
expect(result.type).toBe('datatable');
expect(result.columns).toHaveLength(1);
expect(result.columns[0]).toHaveProperty('name', 'value');
expect(result.columns[0]).toHaveProperty('id', 'value');
expect(result.columns[0].meta).toHaveProperty('type', 'number');
});
});

describe('expression', () => {
it('maps null values to the new column', () => {
return runFn(testTable, { name: 'empty' }).then((result) => {
Expand Down

0 comments on commit a6cb2d0

Please sign in to comment.