grafana/public/app/features/variables/shared/multiOptions.test.ts
Josh Hunt 3c6e0e8ef8
Chore: ESlint import order (#44959)
* 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
2022-04-22 14:33:13 +01:00

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,
});
});
});
});