mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
3c6e0e8ef8
* 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
78 lines
1.8 KiB
TypeScript
78 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,
|
|
});
|
|
});
|
|
});
|
|
});
|