grafana/public/app/features/scenes/variables/variants/ObjectVariable.test.ts
Dominik Prokop 1758ddd457
Scenes: Add query variable support (#59553)
* WIP first attempt to query variable

* regex issue repro demo

* Refresh variable on time range change if refresh specified

* Instantiate variable runner when updating query variable options

* Simplify runners getTarget interface

* Fix issue with variable ot being updated correctly after other variable changed

* Add templateSrv.replace compatibility with query variable

* QueryVariable: use datasource variable as source

* use proper format

* Make sure variables set is correctly updated when query variable errors

* Do not destruct scopedVars when using sceneGraph.interpolate in templateSrv

* Add support for Legacy variables (metricFindQuery)

* Review

* Fix lint

* Test: Add unit for datasource by variable

* test: Add unit for datasource as var

* query: delegate interpolation to datasourceSrv

* Cleanup

Co-authored-by: Ivan Ortega <ivanortegaalba@gmail.com>
2022-12-12 04:01:27 -08:00

20 lines
524 B
TypeScript

import { ObjectVariable } from './ObjectVariable';
describe('ObjectVariable', () => {
describe('getValue', () => {
it('it should return value according to fieldPath', () => {
const variable = new ObjectVariable({
name: 'test',
type: 'custom',
value: {
field1: 'value1',
array: ['value1', 'value2', 'value3'],
},
});
expect(variable.getValue('field1')).toBe('value1');
expect(variable.getValue('array[1]')).toBe('value2');
});
});
});