toDataFrame: detect field properties using in rather than hasOwnProperty (#23673)
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
import { DataFrameDTO, FieldType, TableData, TimeSeries } from '../types/index';
|
||||
import { dateTime } from '../datetime/moment_wrapper';
|
||||
import { MutableDataFrame } from './MutableDataFrame';
|
||||
import { ArrayDataFrame } from './ArrayDataFrame';
|
||||
|
||||
describe('toDataFrame', () => {
|
||||
it('converts timeseries to series', () => {
|
||||
@@ -73,6 +74,19 @@ describe('toDataFrame', () => {
|
||||
expect(again).toBe(input);
|
||||
});
|
||||
|
||||
it('Make sure ArrayDataFrame is used as a DataFrame without modification', () => {
|
||||
const orig = [
|
||||
{ a: 1, b: 2 },
|
||||
{ a: 3, b: 4 },
|
||||
];
|
||||
const array = new ArrayDataFrame(orig);
|
||||
const frame = toDataFrame(array);
|
||||
expect(frame).toEqual(array);
|
||||
expect(frame instanceof ArrayDataFrame).toEqual(true);
|
||||
expect(frame.length).toEqual(orig.length);
|
||||
expect(frame.fields.map(f => f.name)).toEqual(['a', 'b']);
|
||||
});
|
||||
|
||||
it('throws when table rows is not array', () => {
|
||||
expect(() =>
|
||||
toDataFrame({
|
||||
|
||||
Reference in New Issue
Block a user