mergeEnvMappings.spec.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. import {mergeEnvMappings} from './mergeEnvMappings';
  2. describe('mergeEnvMappings', function () {
  3. it('merges two empty mappings', function () {
  4. const envMappingA = {};
  5. const envMappingB = {};
  6. const mergedMapping = mergeEnvMappings(envMappingA, envMappingB);
  7. expect(mergedMapping).toEqual({});
  8. });
  9. it('merges one empty mapping with one filled mapping', function () {
  10. const envMappingA = {};
  11. const envMappingB = {
  12. prod: {in_progress: 0, ok: 1, missed: 0, timeout: 0, error: 0},
  13. };
  14. const mergedMapping = mergeEnvMappings(envMappingA, envMappingB);
  15. expect(mergedMapping).toEqual(envMappingB);
  16. });
  17. it('merges two filled mappings', function () {
  18. const envMappingA = {
  19. prod: {in_progress: 0, ok: 0, missed: 1, timeout: 2, error: 1},
  20. };
  21. const envMappingB = {
  22. prod: {in_progress: 2, ok: 1, missed: 1, timeout: 0, error: 2},
  23. };
  24. const expectedMerged = {
  25. prod: {in_progress: 2, ok: 1, missed: 2, timeout: 2, error: 3},
  26. };
  27. const mergedMapping = mergeEnvMappings(envMappingA, envMappingB);
  28. expect(mergedMapping).toEqual(expectedMerged);
  29. });
  30. it('merges two filled mappings with differing envs', function () {
  31. const envMappingA = {
  32. prod: {in_progress: 1, ok: 0, missed: 1, timeout: 2, error: 1},
  33. };
  34. const envMappingB = {dev: {in_progress: 0, ok: 1, missed: 1, timeout: 0, error: 2}};
  35. const expectedMerged = {
  36. prod: {in_progress: 1, ok: 0, missed: 1, timeout: 2, error: 1},
  37. dev: {in_progress: 0, ok: 1, missed: 1, timeout: 0, error: 2},
  38. };
  39. const mergedMapping = mergeEnvMappings(envMappingA, envMappingB);
  40. expect(mergedMapping).toEqual(expectedMerged);
  41. });
  42. });