Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
yesoreyeram committed Nov 12, 2024
1 parent bdcb7a3 commit d4c879a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/datasource/responseHandler.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { FieldType, MutableDataFrame, TIME_SERIES_TIME_FIELD_NAME } from '@grafana/data';
import { convertToWide } from './responseHandler';

describe('convertToWide', () => {
it('merge multiple SLI frames correctly', () => {
let frames = convertToWide([
new MutableDataFrame({
name: 'SLI',
fields: [
{ name: TIME_SERIES_TIME_FIELD_NAME, values: [1], type: FieldType.time },
{ name: TIME_SERIES_TIME_FIELD_NAME, values: [1.1], type: FieldType.number },
],
}),
new MutableDataFrame({
name: 'SLI',
fields: [
{ name: TIME_SERIES_TIME_FIELD_NAME, values: [1], type: FieldType.time },
{ name: TIME_SERIES_TIME_FIELD_NAME, values: [1.2], type: FieldType.number },
],
}),
]);
expect(frames.length).toStrictEqual(1);
expect(frames[0].fields.length).toStrictEqual(3);
expect(frames[0].fields[0].values.at(0)).toStrictEqual(1);
expect(frames[0].fields[1].values.at(0)).toStrictEqual(1.1);
expect(frames[0].fields[2].values.at(0)).toStrictEqual(1.2);
});
});

0 comments on commit d4c879a

Please sign in to comment.