mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 07:32:13 +08:00
Variables: Ensures all variable values are strings (#31942)
* Variables: Ensures all variable values are strings * Chore: remove redundant typings * Chore: fixes tests
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
import { findTemplateVarChanges, getCurrentText, getVariableRefresh, isAllVariable } from './utils';
|
||||
import { ensureStringValues, findTemplateVarChanges, getCurrentText, getVariableRefresh, isAllVariable } from './utils';
|
||||
import { VariableRefresh } from './types';
|
||||
import { UrlQueryMap } from '@grafana/data';
|
||||
|
||||
@ -157,3 +157,19 @@ describe('findTemplateVarChanges', () => {
|
||||
expect(findTemplateVarChanges(a, b)!['var-test']).toEqual(['test']);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ensureStringValues', () => {
|
||||
it.each`
|
||||
value | expected
|
||||
${null} | ${''}
|
||||
${undefined} | ${''}
|
||||
${{}} | ${''}
|
||||
${{ current: {} }} | ${''}
|
||||
${1} | ${'1'}
|
||||
${[1, 2]} | ${['1', '2']}
|
||||
${'1'} | ${'1'}
|
||||
${['1', '2']} | ${['1', '2']}
|
||||
`('when called with value:$value then result should be:$expected', ({ value, expected }) => {
|
||||
expect(ensureStringValues(value)).toEqual(expected);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user