mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master merge
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import InputDatasource, { describeDataFrame } from './InputDatasource';
|
|
import { InputQuery, InputOptions } from './types';
|
|
import { readCSV, DataFrame, MutableDataFrame, DataSourceInstanceSettings, PluginMeta } from '@grafana/data';
|
|
|
|
import { getQueryOptions } from 'test/helpers/getQueryOptions';
|
|
|
|
describe('InputDatasource', () => {
|
|
const data = readCSV('a,b,c\n1,2,3\n4,5,6');
|
|
const instanceSettings: DataSourceInstanceSettings<InputOptions> = {
|
|
id: 1,
|
|
type: 'x',
|
|
name: 'xxx',
|
|
meta: {} as PluginMeta,
|
|
jsonData: {
|
|
data,
|
|
},
|
|
};
|
|
|
|
describe('when querying', () => {
|
|
test('should return the saved data with a query', () => {
|
|
const ds = new InputDatasource(instanceSettings);
|
|
const options = getQueryOptions<InputQuery>({
|
|
targets: [{ refId: 'Z' }],
|
|
});
|
|
|
|
return ds.query(options).then(rsp => {
|
|
expect(rsp.data.length).toBe(1);
|
|
|
|
const series: DataFrame = rsp.data[0];
|
|
expect(series.refId).toBe('Z');
|
|
expect(series.fields[0].values).toEqual(data[0].fields[0].values);
|
|
});
|
|
});
|
|
});
|
|
|
|
test('DataFrame descriptions', () => {
|
|
expect(describeDataFrame([])).toEqual('');
|
|
expect(describeDataFrame(null)).toEqual('');
|
|
expect(
|
|
describeDataFrame([
|
|
new MutableDataFrame({
|
|
name: 'x',
|
|
fields: [{ name: 'a' }],
|
|
}),
|
|
])
|
|
).toEqual('1 Fields, 0 Rows');
|
|
});
|
|
});
|