Files
grafana/public/app/plugins/datasource/zipkin/utils/graphTransform.test.ts
Josh Hunt 3c6e0e8ef8 Chore: ESlint import order (#44959)
* Add and configure eslint-plugin-import

* Fix the lint:ts npm command

* Autofix + prettier all the files

* Manually fix remaining files

* Move jquery code in jest-setup to external file to safely reorder imports

* Resolve issue caused by circular dependencies within Prometheus

* Update .betterer.results

* Fix missing // @ts-ignore

* ignore iconBundle.ts

* Fix missing // @ts-ignore
2022-04-22 14:33:13 +01:00

78 lines
2.0 KiB
TypeScript

import { ZipkinSpan } from '../types';
import { createGraphFrames } from './graphTransform';
import {
testResponse,
testResponseEdgesFields,
testResponseNodesFields,
toEdgesFrame,
toNodesFrame,
} from './testResponse';
describe('createGraphFrames', () => {
it('transforms basic response into nodes and edges frame', async () => {
const frames = createGraphFrames(testResponse);
expect(frames.length).toBe(2);
expect(frames[0].fields).toMatchObject(testResponseNodesFields);
expect(frames[1].fields).toMatchObject(testResponseEdgesFields);
});
it('handles single span response', async () => {
const frames = createGraphFrames(singleSpanResponse);
expect(frames.length).toBe(2);
expect(frames[0].fields).toMatchObject(
toNodesFrame([
['3fa414edcef6ad90'],
['tempo-querier'],
['HTTP GET - api_traces_traceid'],
['1049.14ms (100%)'],
['1049.14ms (100%)'],
[1],
])
);
expect(frames[1].fields).toMatchObject(toEdgesFrame([[], [], []]));
});
it('handles missing spans', async () => {
const frames = createGraphFrames(missingSpanResponse);
expect(frames.length).toBe(2);
expect(frames[0].length).toBe(2);
expect(frames[1].length).toBe(0);
});
});
export const singleSpanResponse: ZipkinSpan[] = [
{
traceId: '3fa414edcef6ad90',
id: '3fa414edcef6ad90',
name: 'HTTP GET - api_traces_traceid',
timestamp: 1605873894680409,
duration: 1049141,
tags: {
component: 'gRPC',
spanKind: 'client',
},
localEndpoint: {
serviceName: 'tempo-querier',
},
},
];
export const missingSpanResponse: ZipkinSpan[] = [
{
traceId: '3fa414edcef6ad90',
id: '1',
name: 'HTTP GET - api_traces_traceid',
timestamp: 1605873894680409,
duration: 1049141,
},
{
traceId: '3fa414edcef6ad90',
id: '2',
name: 'HTTP GET - api_traces_traceid',
parentId: '3',
timestamp: 1605873894680409,
duration: 1049141,
},
];