mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
* Templating: __data __field and __series macros * filter out datacontext from json serialization * Fix condition * Update * Added test cases for formatting data, and field macros
34 lines
864 B
TypeScript
34 lines
864 B
TypeScript
import { toDataFrame } from '@grafana/data';
|
|
|
|
import { getTemplateProxyForField } from './templateProxies';
|
|
|
|
describe('Template proxies', () => {
|
|
it('supports name and displayName', () => {
|
|
const frames = [
|
|
toDataFrame({
|
|
fields: [
|
|
{
|
|
name: '🔥',
|
|
config: { displayName: '✨' },
|
|
labels: {
|
|
b: 'BBB',
|
|
a: 'AAA',
|
|
},
|
|
},
|
|
],
|
|
}),
|
|
];
|
|
|
|
const f = getTemplateProxyForField(frames[0].fields[0], frames[0], frames);
|
|
|
|
expect(f.name).toEqual('🔥');
|
|
expect(f.displayName).toEqual('✨');
|
|
expect(`${f.labels}`).toEqual('a="AAA", b="BBB"');
|
|
expect(f.labels.__values).toEqual('AAA, BBB');
|
|
expect(f.labels.a).toEqual('AAA');
|
|
|
|
// Deprecated syntax
|
|
expect(`${f.formattedLabels}`).toEqual('a="AAA", b="BBB"');
|
|
});
|
|
});
|