mirror of
https://github.com/grafana/grafana.git
synced 2025-01-06 14:13:11 -06:00
00a9af00fc
* Chore: initial commit * Tests: fixes MetricsQueryEditor.test.tsx * Tests: fixes cloudwatch/specs/datasource.test.ts * Tests: fixes stackdriver/specs/datasource.test.ts * Tests: remove refrences to CustomVariable * Refactor: moves DefaultVariableQueryEditor * Refactor: moves utils * Refactor: moves types * Refactor: removes variableSrv * Refactor: removes feature toggle newVariables * Refactor: removes valueSelectDropDown * Chore: removes GeneralTabCtrl * Chore: migrates RowOptions * Refactor: adds RowOptionsButton * Refactor: makes the interface more explicit * Refactor: small changes * Refactor: changed type as it can be any variable type * Tests: fixes broken test * Refactor: changes after PR comments * Refactor: adds loading state and call to onChange in componentDidMount
77 lines
1.8 KiB
TypeScript
77 lines
1.8 KiB
TypeScript
import { VariableOption } from 'app/features/variables/types';
|
|
import { alignCurrentWithMulti } from './multiOptions';
|
|
|
|
describe('alignCurrentWithMulti', () => {
|
|
describe('when current has string array values and multi is false', () => {
|
|
it('should return current without string arrays', () => {
|
|
const current: VariableOption = {
|
|
value: ['A'],
|
|
text: ['A'],
|
|
selected: false,
|
|
};
|
|
|
|
const next = alignCurrentWithMulti(current, false);
|
|
|
|
expect(next).toEqual({
|
|
value: 'A',
|
|
text: 'A',
|
|
selected: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when current has string values and multi is true', () => {
|
|
it('should return current with string arrays', () => {
|
|
const current: VariableOption = {
|
|
value: 'A',
|
|
text: 'A',
|
|
selected: false,
|
|
};
|
|
|
|
const next = alignCurrentWithMulti(current, true);
|
|
|
|
expect(next).toEqual({
|
|
value: ['A'],
|
|
text: ['A'],
|
|
selected: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when current has string values and multi is false', () => {
|
|
it('should return current without string arrays', () => {
|
|
const current: VariableOption = {
|
|
value: 'A',
|
|
text: 'A',
|
|
selected: false,
|
|
};
|
|
|
|
const next = alignCurrentWithMulti(current, false);
|
|
|
|
expect(next).toEqual({
|
|
value: 'A',
|
|
text: 'A',
|
|
selected: false,
|
|
});
|
|
});
|
|
});
|
|
|
|
describe('when current has string array values and multi is true', () => {
|
|
it('should return current with string arrays', () => {
|
|
const current: VariableOption = {
|
|
value: ['A'],
|
|
text: ['A'],
|
|
selected: false,
|
|
};
|
|
|
|
const next = alignCurrentWithMulti(current, true);
|
|
|
|
expect(next).toEqual({
|
|
value: ['A'],
|
|
text: ['A'],
|
|
selected: false,
|
|
});
|
|
});
|
|
});
|
|
});
|