multiOptions.test.ts 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import { VariableOption } from 'app/features/variables/types';
  2. import { alignCurrentWithMulti } from './multiOptions';
  3. describe('alignCurrentWithMulti', () => {
  4. describe('when current has string array values and multi is false', () => {
  5. it('should return current without string arrays', () => {
  6. const current: VariableOption = {
  7. value: ['A'],
  8. text: ['A'],
  9. selected: false,
  10. };
  11. const next = alignCurrentWithMulti(current, false);
  12. expect(next).toEqual({
  13. value: 'A',
  14. text: 'A',
  15. selected: false,
  16. });
  17. });
  18. });
  19. describe('when current has string values and multi is true', () => {
  20. it('should return current with string arrays', () => {
  21. const current: VariableOption = {
  22. value: 'A',
  23. text: 'A',
  24. selected: false,
  25. };
  26. const next = alignCurrentWithMulti(current, true);
  27. expect(next).toEqual({
  28. value: ['A'],
  29. text: ['A'],
  30. selected: false,
  31. });
  32. });
  33. });
  34. describe('when current has string values and multi is false', () => {
  35. it('should return current without string arrays', () => {
  36. const current: VariableOption = {
  37. value: 'A',
  38. text: 'A',
  39. selected: false,
  40. };
  41. const next = alignCurrentWithMulti(current, false);
  42. expect(next).toEqual({
  43. value: 'A',
  44. text: 'A',
  45. selected: false,
  46. });
  47. });
  48. });
  49. describe('when current has string array values and multi is true', () => {
  50. it('should return current with string arrays', () => {
  51. const current: VariableOption = {
  52. value: ['A'],
  53. text: ['A'],
  54. selected: false,
  55. };
  56. const next = alignCurrentWithMulti(current, true);
  57. expect(next).toEqual({
  58. value: ['A'],
  59. text: ['A'],
  60. selected: false,
  61. });
  62. });
  63. });
  64. });