2020-06-04 06:44:48 -05:00
|
|
|
import { VariableOption } from 'app/features/variables/types';
|
2022-04-22 08:33:13 -05:00
|
|
|
|
2020-04-01 11:13:38 -05:00
|
|
|
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,
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|